-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathup_only_pgsql_16.txt
More file actions
18 lines (18 loc) · 1.09 KB
/
up_only_pgsql_16.txt
File metadata and controls
18 lines (18 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#---------- UP ----------
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';
#---------- DOWN ----------