@@ -751,6 +751,7 @@ public void RecreateTable(SQLiteTableInfo sqliteTableInfo)
751
751
752
752
var dbFields = columnDbFields . Concat ( foreignKeyDbFields )
753
753
. Concat ( uniqueDbFields )
754
+ . Concat ( checkConstraintDbFields )
754
755
. ToArray ( ) ;
755
756
756
757
// ToHashSet() not available in older .NET versions so we create it old-fashioned.
@@ -811,6 +812,12 @@ public void RecreateTable(SQLiteTableInfo sqliteTableInfo)
811
812
}
812
813
}
813
814
815
+ [ Obsolete ]
816
+ public override void AddTable ( string table , string engine , string columns )
817
+ {
818
+ throw new NotSupportedException ( ) ;
819
+ }
820
+
814
821
public override void AddColumn ( string table , Column column )
815
822
{
816
823
if ( ! TableExists ( table ) )
@@ -819,6 +826,7 @@ public override void AddColumn(string table, Column column)
819
826
}
820
827
821
828
var sqliteInfo = GetSQLiteTableInfo ( table ) ;
829
+
822
830
if ( sqliteInfo . ColumnMappings . Select ( x => x . OldName ) . ToList ( ) . Contains ( column . Name ) )
823
831
{
824
832
throw new Exception ( "Column already exists." ) ;
@@ -830,6 +838,61 @@ public override void AddColumn(string table, Column column)
830
838
RecreateTable ( sqliteInfo ) ;
831
839
}
832
840
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
+
833
896
public override void ChangeColumn ( string table , Column column )
834
897
{
835
898
if ( ! TableExists ( table ) )
@@ -910,9 +973,12 @@ public override string[] GetConstraints(string table)
910
973
. Select ( x => x . Name )
911
974
. ToList ( ) ;
912
975
913
- // TODO add PK and CHECK
976
+ var checkConstraints = sqliteInfo . CheckConstraints
977
+ . Select ( x => x . Name )
978
+ . ToList ( ) ;
914
979
915
980
var names = foreignKeyNames . Concat ( uniqueConstraints )
981
+ . Concat ( checkConstraints )
916
982
. Where ( x => ! string . IsNullOrWhiteSpace ( x ) )
917
983
. ToArray ( ) ;
918
984
@@ -1471,6 +1537,16 @@ public List<PragmaTableInfoItem> GetPragmaTableInfoItems(string tableNameNotQuot
1471
1537
return pragmaTableInfoItems ;
1472
1538
}
1473
1539
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
+
1474
1550
public List < CheckConstraint > GetCheckConstraints ( string tableName )
1475
1551
{
1476
1552
if ( ! TableExists ( tableName ) )
0 commit comments