Beispiel #1
0
 public ICreateConstraints AddForeignKeyOn(string columnNames, string parentTable, string parentColumns,
                                           ForeignKeyRelationCascade onUpdate =
                                           ForeignKeyRelationCascade.NoAction,
                                           ForeignKeyRelationCascade onDelete =
                                           ForeignKeyRelationCascade.NoAction, string keyName = null)
 {
     _current = Schema.AddForeignKey(columnNames, parentTable, parentColumns, onUpdate, onDelete, keyName);
     return(this);
 }
 protected virtual void Write(ConstraintDefinition constraint)
 {
     _definition = constraint;
     constraint.Options.Use(Engine);
     if (constraint.IsRedefined(Engine))
     {
         Builder.Append(constraint.GetDefinition(Engine));
         return;
     }
     Builder.Append(" CONSTRAINT");
     var name = ConstraintName(constraint.Name);
     if (!name.IsNullOrEmpty())
     {
         Builder.AppendFormat(" {0} ", name);
     }
     WriteConstraintType();
     Builder.Append(" (");
     WriteConstraintFeature();
     Builder.Append(")");
 }
Beispiel #3
0
 public IDefineSpecificConstraintsOptions this[string name]
 {
     get
     {
         name.MustNotBeEmpty();
         _current = Schema.Checks.Find(d => d.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
         if (_current == null)
         {
             _current = Schema.Uniques.Find(d => d.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
             if (_current == null)
             {
                 if (Schema.PrimaryKey.Name == name)
                 {
                     _current = Schema.PrimaryKey;
                 }
                 else
                 {
                     throw new ArgumentException("Constraint not found", name);
                 }
             }
         }
         return(this);
     }
 }
Beispiel #4
0
 protected override void Write(ConstraintDefinition constraint)
 {
     //mysql ignores checks
 }
Beispiel #5
0
 public ICreateConstraints AddCheck(string expression, string constraintName)
 {
     _current = Schema.AddCheck(expression, constraintName);
     return(this);
 }
Beispiel #6
0
 public ICreateConstraints AddUniqueConstraintOn(string columnsNames, string constraintName = null)
 {
     _current = Schema.AddUnique(columnsNames, constraintName);
     return(this);
 }