-
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.
finish seeding scripts and other bugs/improvements
- Loading branch information
Connor Bechthold
committed
Jan 31, 2024
1 parent
8382e84
commit cc99796
Showing
16 changed files
with
541 additions
and
59 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
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
43 changes: 43 additions & 0 deletions
43
backend/migrations/versions/6ba7859cdf27_add_unique_constraint_to_combined_.py
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,43 @@ | ||
"""add unique constraint to combined resident id | ||
Revision ID: 6ba7859cdf27 | ||
Revises: a1f05c8f324c | ||
Create Date: 2024-01-29 02:25:45.352261 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '6ba7859cdf27' | ||
down_revision = 'a1f05c8f324c' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('entities') | ||
with op.batch_alter_table('residents', schema=None) as batch_op: | ||
batch_op.create_unique_constraint(None, ['initial', 'room_num']) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('residents', schema=None) as batch_op: | ||
batch_op.drop_constraint(None, type_='unique') | ||
|
||
op.create_table('entities', | ||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), | ||
sa.Column('string_field', sa.VARCHAR(), autoincrement=False, nullable=False), | ||
sa.Column('int_field', sa.INTEGER(), autoincrement=False, nullable=False), | ||
sa.Column('enum_field', postgresql.ENUM('A', 'B', 'C', 'D', name='enum'), autoincrement=False, nullable=False), | ||
sa.Column('string_array_field', postgresql.ARRAY(sa.VARCHAR()), autoincrement=False, nullable=False), | ||
sa.Column('bool_field', sa.BOOLEAN(), autoincrement=False, nullable=False), | ||
sa.Column('file_name', sa.VARCHAR(), autoincrement=False, nullable=True), | ||
sa.PrimaryKeyConstraint('id', name='entities_pkey') | ||
) | ||
# ### end Alembic commands ### |
38 changes: 38 additions & 0 deletions
38
backend/migrations/versions/eff8a5a7fda3_change_resident_room_number_to_be_string.py
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,38 @@ | ||
"""change resident room number to be string | ||
Revision ID: eff8a5a7fda3 | ||
Revises: 6ba7859cdf27 | ||
Create Date: 2024-01-31 04:13:02.272243 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'eff8a5a7fda3' | ||
down_revision = '6ba7859cdf27' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('residents', schema=None) as batch_op: | ||
batch_op.alter_column('room_num', | ||
existing_type=sa.INTEGER(), | ||
type_=sa.String(), | ||
existing_nullable=False) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('residents', schema=None) as batch_op: | ||
batch_op.alter_column('room_num', | ||
existing_type=sa.String(), | ||
type_=sa.INTEGER(), | ||
existing_nullable=False) | ||
|
||
# ### end Alembic commands ### |
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,22 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -u | ||
|
||
function create_user_and_database() { | ||
local database=$1 | ||
echo " Creating user and database '$database'" | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL | ||
CREATE USER $database; | ||
CREATE DATABASE $database; | ||
GRANT ALL PRIVILEGES ON DATABASE $database TO $database; | ||
EOSQL | ||
} | ||
|
||
if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then | ||
echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES" | ||
for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do | ||
create_user_and_database $db | ||
done | ||
echo "Multiple databases created" | ||
fi |
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
Oops, something went wrong.