@@ -751,6 +751,7 @@ public void RecreateTable(SQLiteTableInfo sqliteTableInfo)
751751
752752 var dbFields = columnDbFields . Concat ( foreignKeyDbFields )
753753 . Concat ( uniqueDbFields )
754+ . Concat ( checkConstraintDbFields )
754755 . ToArray ( ) ;
755756
756757 // ToHashSet() not available in older .NET versions so we create it old-fashioned.
@@ -811,6 +812,12 @@ public void RecreateTable(SQLiteTableInfo sqliteTableInfo)
811812 }
812813 }
813814
815+ [ Obsolete ]
816+ public override void AddTable ( string table , string engine , string columns )
817+ {
818+ throw new NotSupportedException ( ) ;
819+ }
820+
814821 public override void AddColumn ( string table , Column column )
815822 {
816823 if ( ! TableExists ( table ) )
@@ -819,6 +826,7 @@ public override void AddColumn(string table, Column column)
819826 }
820827
821828 var sqliteInfo = GetSQLiteTableInfo ( table ) ;
829+
822830 if ( sqliteInfo . ColumnMappings . Select ( x => x . OldName ) . ToList ( ) . Contains ( column . Name ) )
823831 {
824832 throw new Exception ( "Column already exists." ) ;
@@ -830,6 +838,61 @@ public override void AddColumn(string table, Column column)
830838 RecreateTable ( sqliteInfo ) ;
831839 }
832840
841+ public override void AddColumn ( string table , string columnName , DbType type , ColumnProperty property )
842+ {
843+ var column = new Column ( columnName , type , property ) ;
844+
845+ AddColumn ( table , column ) ;
846+ }
847+
848+ public override void AddColumn ( string table , string columnName , MigratorDbType type , ColumnProperty property )
849+ {
850+ var column = new Column ( columnName , type , property ) ;
851+
852+ AddColumn ( table , column ) ;
853+ }
854+
855+ public override void AddColumn ( string table , string columnName , DbType type )
856+ {
857+ var column = new Column ( columnName , type ) ;
858+
859+ AddColumn ( table , column ) ;
860+ }
861+
862+ public override void AddColumn ( string table , string columnName , MigratorDbType type )
863+ {
864+ var column = new Column ( columnName , type ) ;
865+
866+ AddColumn ( table , column ) ;
867+ }
868+
869+ public override void AddColumn ( string table , string columnName , DbType type , int size , ColumnProperty property )
870+ {
871+ var column = new Column ( columnName , type , size , property ) ;
872+
873+ AddColumn ( table , column ) ;
874+ }
875+
876+ public override void AddColumn ( string table , string columnName , MigratorDbType type , int size , ColumnProperty property )
877+ {
878+ var column = new Column ( columnName , type , size , property ) ;
879+
880+ AddColumn ( table , column ) ;
881+ }
882+
883+ public override void AddColumn ( string table , string columnName , DbType type , object defaultValue )
884+ {
885+ var column = new Column ( columnName , type , defaultValue ) ;
886+
887+ AddColumn ( table , column ) ;
888+ }
889+
890+ public override void AddColumn ( string table , string sqlColumn )
891+ {
892+ var column = new Column ( sqlColumn ) ;
893+ AddColumn ( table , column ) ;
894+ }
895+
833896 public override void ChangeColumn ( string table , Column column )
834897 {
835898 if ( ! TableExists ( table ) )
@@ -910,9 +973,12 @@ public override string[] GetConstraints(string table)
910973 . Select ( x => x . Name )
911974 . ToList ( ) ;
912975
913- // TODO add PK and CHECK
976+ var checkConstraints = sqliteInfo . CheckConstraints
977+ . Select ( x => x . Name )
978+ . ToList ( ) ;
914979
915980 var names = foreignKeyNames . Concat ( uniqueConstraints )
981+ . Concat ( checkConstraints )
916982 . Where ( x => ! string . IsNullOrWhiteSpace ( x ) )
917983 . ToArray ( ) ;
918984
@@ -1471,6 +1537,16 @@ public List<PragmaTableInfoItem> GetPragmaTableInfoItems(string tableNameNotQuot
14711537 return pragmaTableInfoItems ;
14721538 }
14731539
1540+ public override void AddCheckConstraint ( string constraintName , string tableName , string checkSql )
1541+ {
1542+ var sqliteTableInfo = GetSQLiteTableInfo ( tableName ) ;
1543+
1544+ var checkConstraint = new CheckConstraint ( constraintName , checkSql ) ;
1545+ sqliteTableInfo . CheckConstraints . Add ( checkConstraint ) ;
1546+
1547+ RecreateTable ( sqliteTableInfo ) ;
1548+ }
1549+
14741550 public List < CheckConstraint > GetCheckConstraints ( string tableName )
14751551 {
14761552 if ( ! TableExists ( tableName ) )
0 commit comments