Skip to content

Commit 012d411

Browse files
Add mention of sqlite constraints
1 parent d190ca8 commit 012d411

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

sql-parser/sqlite.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func (p *Parser) Visit(node sqlite.Node) (w sqlite.Visitor, n sqlite.Node, err e
134134

135135
func (p *Parser) parseSqliteConstrains(tbName string, columnDefinition *sqlite.ColumnDefinition) []*ast.ColumnOption {
136136
// https://www.sqlite.org/syntax/column-constraint.html
137+
// Also, Sqlite does not support dropping constraints, so we safely can add them here
137138
conss := columnDefinition.Constraints
138139
opts := []*ast.ColumnOption{}
139140
for _, cons := range conss {

test/sqlite/migration_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ func TestMigrationGeneratorSingleTable(t *testing.T) {
2121
t.Fatalf("failed to parse schema: %v", err)
2222
}
2323

24-
sqlizeCurrent.StringUp()
25-
sqlizeCurrent.StringDown()
24+
runVariousMigrationFunctions(t, sqlizeCurrent)
25+
}
26+
27+
func runVariousMigrationFunctions(t *testing.T, s *sqlize.Sqlize) {
28+
s.StringUp()
29+
s.StringDown()
2630

27-
sqlizeCurrent.StringUpWithVersion(0, false)
28-
sqlizeCurrent.StringDownWithVersion(0)
31+
s.StringUpWithVersion(0, false)
32+
s.StringDownWithVersion(0)
2933

30-
sqlizeCurrent.StringUpWithVersion(123, false)
31-
sqlizeCurrent.StringDownWithVersion(123)
34+
s.StringUpWithVersion(123, false)
35+
s.StringDownWithVersion(123)
3236
}

0 commit comments

Comments
 (0)