2021-02-10 09:12:42 +01:00
|
|
|
-- Your SQL goes here
|
2021-02-14 22:28:34 +01:00
|
|
|
|
|
|
|
ALTER TABLE users ADD COLUMN role INTEGER DEFAULT 1 NOT NULL;
|
|
|
|
CREATE TABLE usersnew
|
2021-02-10 09:12:42 +01:00
|
|
|
(
|
|
|
|
id INTEGER PRIMARY KEY NOT NULL,
|
2021-02-14 22:28:34 +01:00
|
|
|
username VARCHAR NOT NULL,
|
|
|
|
email VARCHAR NOT NULL,
|
|
|
|
password VARCHAR NOT NULL,
|
|
|
|
role INTEGER DEFAULT 1 NOT NULL,
|
2021-02-10 09:12:42 +01:00
|
|
|
|
2021-02-14 22:28:34 +01:00
|
|
|
UNIQUE(username, email),
|
2021-02-10 09:12:42 +01:00
|
|
|
FOREIGN KEY
|
2021-02-14 22:28:34 +01:00
|
|
|
(role) REFERENCES user_roles
|
|
|
|
(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO usersnew
|
|
|
|
SELECT *
|
|
|
|
FROM users;
|
|
|
|
DROP TABLE users;
|
|
|
|
|
|
|
|
ALTER TABLE usersnew
|
|
|
|
RENAME TO users;
|
|
|
|
|
|
|
|
UPDATE users SET role=2 where id is 1;
|
|
|
|
|