49 lines
1.6 KiB
SQL
49 lines
1.6 KiB
SQL
-- test user
|
|
INSERT INTO user(name) VALUES('Marie');
|
|
INSERT INTO "user_role" (user_id, role_id) VALUES((SELECT id from user where name = 'Marie'),(SELECT id FROM role where name = 'Donau Linz'));
|
|
INSERT INTO user(name) VALUES('Philipp');
|
|
INSERT INTO "user_role" (user_id, role_id) VALUES((SELECT id from user where name = 'Philipp'),(SELECT id FROM role where name = 'Donau Linz'));
|
|
|
|
|
|
-- Step 1: Create a new table without the 'notes' column
|
|
CREATE TABLE "user_new" (
|
|
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
"name" text NOT NULL UNIQUE,
|
|
"pw" text,
|
|
"deleted" boolean NOT NULL DEFAULT FALSE,
|
|
"last_access" DATETIME,
|
|
"dob" text,
|
|
"weight" text,
|
|
"sex" text,
|
|
"dirty_thirty" text,
|
|
"dirty_dozen" text,
|
|
"member_since_date" text,
|
|
"birthdate" text,
|
|
"mail" text,
|
|
"nickname" text,
|
|
"phone" text,
|
|
"address" text,
|
|
"family_id" INTEGER REFERENCES family(id),
|
|
"membership_pdf" BLOB,
|
|
"user_token" TEXT NOT NULL DEFAULT (lower(hex(randomblob(16))))
|
|
);
|
|
|
|
-- Step 2: Copy data from the old table to the new one (excluding 'notes')
|
|
INSERT INTO user_new (
|
|
id, name, pw, deleted, last_access, dob, weight, sex,
|
|
dirty_thirty, dirty_dozen, member_since_date, birthdate,
|
|
mail, nickname, phone, address, family_id, membership_pdf, user_token
|
|
)
|
|
SELECT
|
|
id, name, pw, deleted, last_access, dob, weight, sex,
|
|
dirty_thirty, dirty_dozen, member_since_date, birthdate,
|
|
mail, nickname, phone, address, family_id, membership_pdf, user_token
|
|
FROM user;
|
|
|
|
-- Step 3: Drop the old table
|
|
DROP TABLE user;
|
|
|
|
-- Step 4: Rename the new table to the original name
|
|
ALTER TABLE user_new RENAME TO user;
|
|
|