@@ -10,20 +10,34 @@ const inputGoose = `
10
10
-- +goose Up
11
11
ALTER TABLE archived_jobs ADD COLUMN expires_at TIMESTAMP WITH TIME ZONE;
12
12
13
+ -- sqlc:ignore
14
+ CREATE TABLE countries (id int);
15
+ CREATE TABLE people (id int);
16
+ -- sqlc:ignore
17
+
13
18
-- +goose Down
14
19
ALTER TABLE archived_jobs DROP COLUMN expires_at;
15
20
`
16
21
17
22
const outputGoose = `
18
23
-- +goose Up
19
24
ALTER TABLE archived_jobs ADD COLUMN expires_at TIMESTAMP WITH TIME ZONE;
25
+
26
+
27
+
28
+
29
+
20
30
`
21
31
22
32
const inputMigrate = `
23
33
-- +migrate Up
24
34
-- SQL in section 'Up' is executed when this migration is applied
25
35
CREATE TABLE people (id int);
26
36
37
+ -- sqlc:ignore
38
+ INVALID SYNTAX HERE IS OK, WE SHOULD IGNORE THIS
39
+ -- sqlc:ignore end
40
+
27
41
-- +migrate Down
28
42
-- SQL section 'Down' is executed when this migration is rolled back
29
43
DROP TABLE people;
@@ -33,47 +47,66 @@ const outputMigrate = `
33
47
-- +migrate Up
34
48
-- SQL in section 'Up' is executed when this migration is applied
35
49
CREATE TABLE people (id int);
50
+
51
+
52
+
53
+
36
54
`
37
55
38
56
const inputTern = `
57
+ -- sqlc:ignore
58
+ As first row also ok, all contents after should be processed
59
+ -- sqlc:ignore end
39
60
-- Write your migrate up statements here
40
61
ALTER TABLE todo RENAME COLUMN done TO is_done;
41
62
---- create above / drop below ----
42
63
ALTER TABLE todo RENAME COLUMN is_done TO done;
43
64
`
44
65
45
66
const outputTern = `
67
+
68
+
69
+
46
70
-- Write your migrate up statements here
47
71
ALTER TABLE todo RENAME COLUMN done TO is_done;`
48
72
49
73
const inputDbmate = `
50
74
-- migrate:up
51
75
CREATE TABLE foo (bar int);
76
+ -- sqlc:ignore
77
+ In up section
78
+ -- sqlc:ignore end
52
79
-- migrate:down
53
- DROP TABLE foo;`
80
+ DROP TABLE foo;
81
+ -- sqlc:ignore
82
+ In down section
83
+ -- sqlc:ignore end`
54
84
55
85
const outputDbmate = `
56
86
-- migrate:up
57
- CREATE TABLE foo (bar int);`
87
+ CREATE TABLE foo (bar int);
88
+
89
+
90
+ `
58
91
59
- func TestRemoveRollback (t * testing.T ) {
60
- if diff := cmp .Diff (outputGoose , RemoveRollbackStatements (inputGoose )); diff != "" {
92
+ func TestRemoveIgnored (t * testing.T ) {
93
+ if diff := cmp .Diff (outputGoose , RemoveIgnoredStatements (inputGoose )); diff != "" {
61
94
t .Errorf ("goose migration mismatch:\n %s" , diff )
62
95
}
63
- if diff := cmp .Diff (outputMigrate , RemoveRollbackStatements (inputMigrate )); diff != "" {
96
+ if diff := cmp .Diff (outputMigrate , RemoveIgnoredStatements (inputMigrate )); diff != "" {
64
97
t .Errorf ("sql-migrate migration mismatch:\n %s" , diff )
65
98
}
66
- if diff := cmp .Diff (outputTern , RemoveRollbackStatements (inputTern )); diff != "" {
99
+ if diff := cmp .Diff (outputTern , RemoveIgnoredStatements (inputTern )); diff != "" {
67
100
t .Errorf ("tern migration mismatch:\n %s" , diff )
68
101
}
69
- if diff := cmp .Diff (outputDbmate , RemoveRollbackStatements (inputDbmate )); diff != "" {
102
+ if diff := cmp .Diff (outputDbmate , RemoveIgnoredStatements (inputDbmate )); diff != "" {
70
103
t .Errorf ("dbmate migration mismatch:\n %s" , diff )
71
104
}
72
105
}
73
106
74
107
func TestRemoveGolangMigrateRollback (t * testing.T ) {
75
108
filenames := map [string ]bool {
76
- // make sure we let through golang-migrate files that aren't rollbacks
109
+ // make sure we let through golang-migrate files that aren't ignored
77
110
"migrations/1.up.sql" : false ,
78
111
// make sure we let through other sql files
79
112
"migrations/2.sql" : false ,
0 commit comments