-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathtemplate_output_pgsql_18.txt
More file actions
36 lines (36 loc) · 2.42 KB
/
template_output_pgsql_18.txt
File metadata and controls
36 lines (36 loc) · 2.42 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
SQL_UP = u"""
DELETE FROM "posts" WHERE "id" = '4';
DELETE FROM "users" WHERE "id" = '4';
-- WARNING: column "status" changed; data may be lost.
ALTER TABLE "users" DROP COLUMN "status";
ALTER TABLE "users" ADD COLUMN "status" varchar(20) DEFAULT 'active'::character varying;
ALTER TABLE "posts" DROP COLUMN "published_at";
ALTER TABLE "users" DROP COLUMN "phone";
ALTER TABLE "users" DROP COLUMN "updated_at";
DROP INDEX "posts_published_idx";
DROP INDEX "users_status_idx";
INSERT INTO "posts" ("id","user_id","title","content","published") VALUES('3','2','Jane Post','This is Jane post content','1');
INSERT INTO "users" ("id","name","email","status","created_at") VALUES('3','Bob Wilson','bob@example.com','inactive','2024-01-01 00:00:00');
UPDATE "posts" SET "title" = 'First Post', "content" = 'This is the first post content' WHERE "id" = '1';
UPDATE "posts" SET "published" = '' WHERE "id" = '2';
UPDATE "users" SET "created_at" = '2024-01-01 00:00:00' WHERE "id" = '1';
UPDATE "users" SET "status" = 'active', "created_at" = '2024-01-01 00:00:00' WHERE "id" = '2';
"""
SQL_DOWN = u"""
DELETE FROM "posts" WHERE "id" = '3';
DELETE FROM "users" WHERE "id" = '3';
-- WARNING: column "status" changed; data may be lost.
ALTER TABLE "users" DROP COLUMN "status";
ALTER TABLE "users" ADD COLUMN "status" varchar(20) DEFAULT 'pending'::character varying;
ALTER TABLE "posts" ADD COLUMN "published_at" timestamp(6);
ALTER TABLE "users" ADD COLUMN "phone" varchar(20) DEFAULT NULL::character varying;
ALTER TABLE "users" ADD COLUMN "updated_at" timestamp(6) DEFAULT '2024-01-01 00:00:00'::timestamp without time zone;
CREATE INDEX posts_published_idx ON public.posts USING btree (published);
CREATE INDEX users_status_idx ON public.users USING btree (status);
INSERT INTO "posts" ("id","user_id","title","content","published","published_at") VALUES('4','4','Alice Post','This is Alice post content','1','2024-01-03 12:00:00');
INSERT INTO "users" ("id","name","email","phone","status","created_at","updated_at") VALUES('4','Alice Brown','alice@example.com','555-9999','active','2024-01-01 00:00:10','2024-01-01 00:00:10');
UPDATE "posts" SET "title" = 'First Post Updated', "content" = 'This is the updated first post content' WHERE "id" = '1';
UPDATE "posts" SET "published" = '1' WHERE "id" = '2';
UPDATE "users" SET "created_at" = '2024-01-01 00:00:10' WHERE "id" = '1';
UPDATE "users" SET "status" = 'pending', "created_at" = '2024-01-01 00:00:10' WHERE "id" = '2';
"""