@@ -10,20 +10,34 @@ const inputGoose = `
1010-- +goose Up
1111ALTER TABLE archived_jobs ADD COLUMN expires_at TIMESTAMP WITH TIME ZONE;
1212
13+ -- sqlc:ignore
14+ CREATE TABLE countries (id int);
15+ CREATE TABLE people (id int);
16+ -- sqlc:ignore
17+
1318-- +goose Down
1419ALTER TABLE archived_jobs DROP COLUMN expires_at;
1520`
1621
1722const outputGoose = `
1823-- +goose Up
1924ALTER TABLE archived_jobs ADD COLUMN expires_at TIMESTAMP WITH TIME ZONE;
25+
26+
27+
28+
29+
2030`
2131
2232const inputMigrate = `
2333-- +migrate Up
2434-- SQL in section 'Up' is executed when this migration is applied
2535CREATE TABLE people (id int);
2636
37+ -- sqlc:ignore
38+ INVALID SYNTAX HERE IS OK, WE SHOULD IGNORE THIS
39+ -- sqlc:ignore end
40+
2741-- +migrate Down
2842-- SQL section 'Down' is executed when this migration is rolled back
2943DROP TABLE people;
@@ -33,47 +47,66 @@ const outputMigrate = `
3347-- +migrate Up
3448-- SQL in section 'Up' is executed when this migration is applied
3549CREATE TABLE people (id int);
50+
51+
52+
53+
3654`
3755
3856const inputTern = `
57+ -- sqlc:ignore
58+ As first row also ok, all contents after should be processed
59+ -- sqlc:ignore end
3960-- Write your migrate up statements here
4061ALTER TABLE todo RENAME COLUMN done TO is_done;
4162---- create above / drop below ----
4263ALTER TABLE todo RENAME COLUMN is_done TO done;
4364`
4465
4566const outputTern = `
67+
68+
69+
4670-- Write your migrate up statements here
4771ALTER TABLE todo RENAME COLUMN done TO is_done;`
4872
4973const inputDbmate = `
5074-- migrate:up
5175CREATE TABLE foo (bar int);
76+ -- sqlc:ignore
77+ In up section
78+ -- sqlc:ignore end
5279-- migrate:down
53- DROP TABLE foo;`
80+ DROP TABLE foo;
81+ -- sqlc:ignore
82+ In down section
83+ -- sqlc:ignore end`
5484
5585const outputDbmate = `
5686-- migrate:up
57- CREATE TABLE foo (bar int);`
87+ CREATE TABLE foo (bar int);
88+
89+
90+ `
5891
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 != "" {
6194 t .Errorf ("goose migration mismatch:\n %s" , diff )
6295 }
63- if diff := cmp .Diff (outputMigrate , RemoveRollbackStatements (inputMigrate )); diff != "" {
96+ if diff := cmp .Diff (outputMigrate , RemoveIgnoredStatements (inputMigrate )); diff != "" {
6497 t .Errorf ("sql-migrate migration mismatch:\n %s" , diff )
6598 }
66- if diff := cmp .Diff (outputTern , RemoveRollbackStatements (inputTern )); diff != "" {
99+ if diff := cmp .Diff (outputTern , RemoveIgnoredStatements (inputTern )); diff != "" {
67100 t .Errorf ("tern migration mismatch:\n %s" , diff )
68101 }
69- if diff := cmp .Diff (outputDbmate , RemoveRollbackStatements (inputDbmate )); diff != "" {
102+ if diff := cmp .Diff (outputDbmate , RemoveIgnoredStatements (inputDbmate )); diff != "" {
70103 t .Errorf ("dbmate migration mismatch:\n %s" , diff )
71104 }
72105}
73106
74107func TestRemoveGolangMigrateRollback (t * testing.T ) {
75108 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
77110 "migrations/1.up.sql" : false ,
78111 // make sure we let through other sql files
79112 "migrations/2.sql" : false ,
0 commit comments