(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func TestDetectModifyTable(t *testing.T) { |
| 22 | var ( |
| 23 | report *sqlcheck.Report |
| 24 | pass = &sqlcheck.Pass{ |
| 25 | Dev: &sqlclient.Client{ |
| 26 | Driver: func() migrate.Driver { |
| 27 | drv := &sqlite.Driver{} |
| 28 | drv.Differ = sqlite.DefaultDiff |
| 29 | return drv |
| 30 | }(), |
| 31 | }, |
| 32 | File: &sqlcheck.File{ |
| 33 | File: testFile{name: "1.sql"}, |
| 34 | Changes: []*sqlcheck.Change{ |
| 35 | // A real drop. |
| 36 | { |
| 37 | Stmt: &migrate.Stmt{ |
| 38 | Text: "DROP TABLE `users`", |
| 39 | }, |
| 40 | Changes: schema.Changes{ |
| 41 | &schema.DropTable{ |
| 42 | T: schema.NewTable("users"). |
| 43 | SetSchema(schema.New("main")), |
| 44 | }, |
| 45 | }, |
| 46 | }, |
| 47 | // Table modification using a temporary table. |
| 48 | { |
| 49 | Stmt: &migrate.Stmt{ |
| 50 | Text: "PRAGMA foreign_keys = off;", |
| 51 | }, |
| 52 | }, |
| 53 | { |
| 54 | Stmt: &migrate.Stmt{ |
| 55 | Text: "CREATE TABLE `new_posts` (`text` text NOT NULL);", |
| 56 | }, |
| 57 | Changes: schema.Changes{ |
| 58 | &schema.AddTable{ |
| 59 | T: schema.NewTable("new_posts"). |
| 60 | SetSchema(schema.New("main")). |
| 61 | AddColumns(schema.NewStringColumn("text", "text")), |
| 62 | }, |
| 63 | }, |
| 64 | }, |
| 65 | { |
| 66 | Stmt: &migrate.Stmt{ |
| 67 | Text: "INSERT INTO `new_posts` (`text`) SELECT `text` FROM `posts`;", |
| 68 | }, |
| 69 | }, |
| 70 | { |
| 71 | Stmt: &migrate.Stmt{ |
| 72 | Text: "DROP TABLE `posts`", |
| 73 | }, |
| 74 | Changes: schema.Changes{ |
| 75 | &schema.DropTable{ |
| 76 | T: schema.NewTable("posts"). |
| 77 | SetSchema(schema.New("main")). |
| 78 | AddColumns( |
nothing calls this directly
no test coverage detected