MCPcopy Create free account
hub / github.com/ariga/atlas / TestDetectModifyTable

Function TestDetectModifyTable

sql/sqlite/sqlitecheck/sqlitecheck_test.go:21–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func 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(

Callers

nothing calls this directly

Calls 11

NewTableFunction · 0.92
NewFunction · 0.92
NewStringColumnFunction · 0.92
NewNullStringColumnFunction · 0.92
NewTimeColumnFunction · 0.92
ReportWriterFuncFuncType · 0.92
AnalyzerForFunction · 0.92
SetSchemaMethod · 0.80
EqualMethod · 0.80
AnalyzeMethod · 0.65
AddColumnsMethod · 0.45

Tested by

no test coverage detected