File: cli-migrate-lint-destructive.txt

package info (click to toggle)
golang-ariga-atlas 0.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,676 kB
  • sloc: javascript: 592; sql: 404; makefile: 10
file content (69 lines) | stat: -rw-r--r-- 1,857 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
only mysql8

atlas migrate lint --dir file://migrations1 --dev-url URL --latest=1 > got.txt
cmp got.txt empty.txt

atlas migrate lint --dir file://migrations2 --dev-url URL --latest=1 > got.txt
cmp got.txt empty.txt

# Expect the command to fail; exit code 1.
! atlas migrate lint --dir file://migrations3 --dev-url URL --latest=1 > got.txt
cmp got.txt expected3.txt

# Expect to log only the connected schema.
! atlas migrate lint --dir file://migrations3 --dev-url URL --log='{{println "current:"}}{{.Schema.Current}}{{println "desired:"}}{{.Schema.Desired}}' --latest=1 > got.txt
cmp got.txt schema3.txt

-- empty.txt --
-- migrations1/1.sql --
CREATE TABLE users (id int);
/* Rename column is not a destructive change. */
ALTER TABLE users RENAME COLUMN id TO oid;

-- migrations2/1.sql --
CREATE TABLE users (id int);

-- migrations2/2.sql --
/* Rename table mixed with rename column is not a destructive change. */
ALTER TABLE users RENAME TO user, RENAME COLUMN id TO oid;

-- migrations3/1.sql --
CREATE TABLE users (id int);

-- migrations3/2.sql --
/* Rename table mixed with rename column is not a destructive change. */
ALTER TABLE users RENAME TO user, RENAME COLUMN id TO oid;

-- migrations3/3.sql --
ALTER TABLE user ADD COLUMN id int, DROP COLUMN oid;

-- expected3.txt --
3.sql: destructive changes detected:

	L1: Dropping non-virtual column "oid"

-- schema3.txt --
current:
table "user" {
  schema = schema.script_cli_migrate_lint_destructive
  column "oid" {
    null = true
    type = int
  }
}
schema "script_cli_migrate_lint_destructive" {
  charset = "utf8mb4"
  collate = "utf8mb4_0900_ai_ci"
}
desired:
table "user" {
  schema = schema.script_cli_migrate_lint_destructive
  column "id" {
    null = true
    type = int
  }
}
schema "script_cli_migrate_lint_destructive" {
  charset = "utf8mb4"
  collate = "utf8mb4_0900_ai_ci"
}