-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathmigrations.data.ts
More file actions
45 lines (39 loc) · 1.17 KB
/
migrations.data.ts
File metadata and controls
45 lines (39 loc) · 1.17 KB
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
export const initial001 = {
up: `CREATE TABLE Category (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
);
CREATE TABLE Post (
id INTEGER PRIMARY KEY,
categoryId INTEGER NOT NULL,
title TEXT NOT NULL,
isPublished NUMERIC NOT NULL DEFAULT 0,
CONSTRAINT Post_fk_categoryId FOREIGN KEY (categoryId)
REFERENCES Category (id) ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT Post_ck_isPublished CHECK (isPublished IN (0, 1))
);
CREATE INDEX Post_ix_categoryId ON Post (categoryId);
INSERT INTO Category (id, name) VALUES (1, 'Test');`,
down: `DROP INDEX Post_ix_categoryId;
DROP TABLE Post;
DROP TABLE Category;`
}
export const someFeature002 = {
up: `CREATE TABLE Test (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
);`,
down: `DROP TABLE Test;`
}
export const testCert003 = {
up: `CREATE TABLE whatever ( certificate TEXT );
INSERT INTO whatever ( certificate ) VALUES (
'-----BEGIN CERTIFICATE-----
some contents
-----END CERTIFICATE-----');`,
down: `DROP TABLE whatever;`
}
export const noDown004 = {
up: `CREATE TABLE IF NOT EXISTS downless ( value TEXT );
INSERT INTO downless ( value ) VALUES ('down migration is optional');`
}