-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(sandbox): update the sandbox sql seed file based on latest d…
…b schema (#2233) refactor(sandbox): updated the sandbox sql seed file based on latest db schema MIGRATION CHANGE: migration-20210421113146- seed update gh-00
- Loading branch information
1 parent
3546826
commit a01b18e
Showing
1 changed file
with
44 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,55 @@ | ||
SET search_path | ||
TO main,public; | ||
|
||
/* Inserting auth clients */ | ||
insert into auth_clients | ||
(client_id, client_secret, secret) | ||
values | ||
('test_client_id', 'test_client_secret', 'secret'); | ||
|
||
-- Inserting roles | ||
insert into roles | ||
(name, permissions, role_type) | ||
values | ||
('Admin', '{CreateTodo,UpdateTodo,DeleteTodo}', 0); | ||
|
||
insert into roles | ||
(name, permissions, role_type) | ||
values | ||
('Others', '{}', 1); | ||
|
||
-- Inserting tenants | ||
insert into tenants | ||
(name, status, key) | ||
values | ||
('Master', 1, 'master'); | ||
|
||
-- Inserting Admin User | ||
insert into users | ||
(first_name, last_name, username, email, default_tenant_id) | ||
select 'Admin', 'User', '[email protected]', '[email protected]', id | ||
from tenants | ||
where key = 'master'; | ||
SET search_path TO main, public; | ||
|
||
ALTER TABLE main.roles | ||
ADD IF NOT EXISTS tenant_id uuid NOT NULL, | ||
ADD IF NOT EXISTS allowed_clients text[], | ||
ADD IF NOT EXISTS description varchar(500); | ||
|
||
ALTER TABLE main.tenants | ||
ADD IF NOT EXISTS website varchar(100); | ||
|
||
ALTER TABLE main.users | ||
ADD IF NOT EXISTS photo_url varchar(250), | ||
ADD IF NOT EXISTS designation varchar(50); | ||
|
||
INSERT INTO main.auth_clients(id, client_id, client_secret, redirect_url, access_token_expiration, refresh_token_expiration, auth_code_expiration, secret) | ||
VALUES ('1', 'test_client_id', 'test_client_secret', '', '900', '3600', '300', 'dGVsZXNjb3BlLWhlYWx0aA=='); | ||
|
||
INSERT INTO main.tenants(name, status, key) | ||
VALUES ('demo', 0, 'demo'); | ||
|
||
INSERT INTO main.roles(name, permissions, role_type, tenant_id) | ||
VALUES ('SuperAdmin', '{CreateTenant,ViewTenant,UpdateTenant,DeleteTenant,CreateTenantUser,10200,10201,10202,10203,10204,10216,10205,10206,10207,10208,10209,10210,10211,10212,10213,10214,10215,2,7008,8000,8001,8002,8003,7001,7002,7003,7004,7005,7006,7007,7008,7009,7010,7011,7012,7013,7014,7015,7016,7017,7018,7019,7020,7021,7022,7023,7024,7025,7026,7027,7028}', 0,( | ||
SELECT | ||
id | ||
FROM | ||
main.tenants | ||
WHERE | ||
key = 'demo')); | ||
|
||
INSERT INTO main.users(first_name, last_name, username, email, auth_client_ids, default_tenant_id) | ||
SELECT 'name', | ||
'', | ||
'[email protected]', | ||
'[email protected]', | ||
'{1}', | ||
id | ||
FROM | ||
main.tenants | ||
WHERE | ||
key = 'demo'; | ||
|
||
|
||
insert into user_tenants | ||
(user_id, tenant_id, status, role_id) | ||
select (select id | ||
from users | ||
where username = '[email protected]'), (select id | ||
from tenants | ||
where key = 'master'), 1, id | ||
where key = 'demo'), 1, id | ||
from roles | ||
where role_type = 0; | ||
where name = 'SuperAdmin'; | ||
|
||
|
||
insert into user_credentials | ||
(user_id, auth_provider, password) | ||
|
@@ -48,4 +58,3 @@ from users | |
where username = '[email protected]'; | ||
update users set auth_client_ids = ARRAY[(select id from auth_clients where client_id = 'test_client_id')::integer]; | ||
|
||
|