-
Notifications
You must be signed in to change notification settings - Fork 0
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 #34 from fabianoflorentino/development
Development to Main
- Loading branch information
Showing
8 changed files
with
69 additions
and
28 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
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,8 +1,11 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
sleep 5 | ||
|
||
psql \ | ||
--host="${POSTGRES_HOST}" \ | ||
--username="${POSTGRES_USER}" \ | ||
--dbname="${POSTGRES_DB}" \ | ||
--file=/app/db/init.sql \ | ||
--no-password | ||
--no-password \ | ||
--dbname="${POSTGRES_DB}" --file=/app/db/init.sql && exit |
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 |
---|---|---|
|
@@ -2,5 +2,7 @@ | |
|
||
set -e | ||
|
||
sleep 5 | ||
|
||
printf "Running migrations...\n" | ||
bundle exec rails db:migrate |
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,2 +1 @@ | ||
TRUNCATE CUSTOMERS CASCADE; | ||
TRUNCATE TRANSACTIONS CASCADE; | ||
CREATE EXTENSION pgcrypto; |
20 changes: 20 additions & 0 deletions
20
db/migrate/20240331143457_add_supervisor_user_to_customers.rb
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
# This migration is used to create a supervisor user with admin role. | ||
class AddSupervisorUserToCustomers < ActiveRecord::Migration[7.1] | ||
SUPERVISOR_PASSWORD = SecureRandom.hex(16) | ||
private_constant :SUPERVISOR_PASSWORD | ||
|
||
def up | ||
execute <<-SQL.squish | ||
INSERT INTO customers (name, email, password, role, created_at, updated_at) | ||
VALUES ('Supervisor', '[email protected]', crypt('#{SUPERVISOR_PASSWORD}', gen_salt('bf')), 'admin', now(), now()) | ||
SQL | ||
end | ||
|
||
def down | ||
execute <<-SQL.squish | ||
DELETE FROM customers WHERE email = '[email protected]' AND name = 'Supervisor' | ||
SQL | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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