2020-05-21 17:02:16 +02:00
|
|
|
DROP TABLE IF EXISTS user_projects CASCADE;
|
|
|
|
CREATE TABLE user_projects (
|
|
|
|
id serial primary key not null,
|
|
|
|
user_id int not null references users (id),
|
|
|
|
project_id int not null references projects (id),
|
|
|
|
is_default bool not null default false,
|
|
|
|
is_current bool not null default false,
|
2023-04-01 22:31:57 +02:00
|
|
|
role "UserRoleMapping" not null default 'user',
|
2020-05-21 17:02:16 +02:00
|
|
|
created_at timestamp not null default now(),
|
|
|
|
updated_at timestamp not null default now()
|
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO user_projects (user_id, project_id, role, is_default, is_current)
|
|
|
|
SELECT id, project_id, role, true, true
|
|
|
|
FROM users;
|
|
|
|
|
|
|
|
ALTER TABLE users DROP COLUMN role;
|
|
|
|
ALTER TABLE users DROP COLUMN project_id;
|