-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Throyer/development
Migrate database to postgresql
- Loading branch information
Showing
14 changed files
with
74 additions
and
66 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
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
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
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
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
27 changes: 10 additions & 17 deletions
27
src/main/resources/db/migration/V1639098485493__insert_admin_and_roles.sql
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,31 +1,24 @@ | ||
-- variables | ||
SET @name = 'admin'; | ||
SET @email = '[email protected]'; | ||
SET @password = '$2a$10$QBuMJLbVmHzgvTwpxDynSetACNdCBjU5zgo.81RWEDzH46aUrgcNK'; | ||
SET @adm = 'ADM'; | ||
SET @user = 'USER'; | ||
|
||
-- insert admin | ||
INSERT INTO user | ||
(name, email, password) | ||
INSERT INTO "user" | ||
("name", email, password) | ||
VALUES | ||
(@name, @email, @password); | ||
('admin', 'admin@email.com', '$2a$10$QBuMJLbVmHzgvTwpxDynSetACNdCBjU5zgo.81RWEDzH46aUrgcNK'); | ||
|
||
-- insert roles | ||
INSERT INTO role | ||
INSERT INTO "role" | ||
(name, initials, description, created_by) | ||
VALUES | ||
('ADMINISTRADOR', @adm, 'Administrador do sistema', (SELECT id FROM user WHERE email = @email)), | ||
('USER', @user, 'Usuário do sistema', (SELECT id FROM user WHERE email = @email)); | ||
('ADMINISTRADOR', 'ADM', 'Administrador do sistema', (SELECT id FROM "user" WHERE email = 'admin@email.com')), | ||
('USER', 'USER', 'Usuário do sistema', (SELECT id FROM "user" WHERE email = 'admin@email.com')); | ||
|
||
-- put roles into admin | ||
INSERT INTO user_role | ||
(user_id, role_id) | ||
VALUES | ||
( | ||
(SELECT id FROM user WHERE email = @email), | ||
(SELECT id FROM role WHERE initials = @adm) | ||
(SELECT id FROM "user" WHERE email = 'admin@email.com'), | ||
(SELECT id FROM "role" WHERE initials = 'ADM') | ||
),( | ||
(SELECT id FROM user WHERE email = @email), | ||
(SELECT id FROM role WHERE initials = @user) | ||
(SELECT id FROM "user" WHERE email = 'admin@email.com'), | ||
(SELECT id FROM "role" WHERE initials = 'USER') | ||
); |
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