servnest/db/migrations/003-add-account-type.sql
2022-11-07 19:40:40 +01:00

21 lines
703 B
SQL

BEGIN TRANSACTION;
-- Add column
ALTER TABLE "users" ADD COLUMN "type" TEXT NOT NULL DEFAULT "testing";
-- Remove it's default value
CREATE TABLE "users_temp" (
"id" INTEGER NOT NULL UNIQUE,
"username" TEXT NOT NULL UNIQUE,
"password" TEXT NOT NULL,
"registration_date" TEXT NOT NULL,
"bucket_tokens" INTEGER NOT NULL,
"bucket_last_update" INTEGER NOT NULL,
"type" TEXT NOT NULL,
PRIMARY KEY("id" AUTOINCREMENT)
);
INSERT INTO "users_temp" SELECT "id","username","password","registration_date","bucket_tokens","bucket_last_update","type" FROM "users";
DROP TABLE "users";
ALTER TABLE "users_temp" RENAME TO "users";
COMMIT;