-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include time_created/time_updated on every model 🛢 (#225)
* Include time_created/time_updated on every model. * Client-side updates don't do anything in migrations. * Don't drop slot's time_updated because we didn't make it! * Migration merge commit.
- Loading branch information
1 parent
c687fde
commit 8bd4106
Showing
4 changed files
with
78 additions
and
14 deletions.
There are no files selected for viewing
This file was deleted.
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
42 changes: 42 additions & 0 deletions
42
...ppointment/migrations/versions/2024_01_10_2259-502c76bc79e0_add_time_created_and_time_.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,42 @@ | ||
"""add time_created and time_updated to tables | ||
Revision ID: 502c76bc79e0 | ||
Revises: 0dc429ca07f5 | ||
Create Date: 2024-01-10 22:59:02.194281 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy import func | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '502c76bc79e0' | ||
down_revision = '0dc429ca07f5' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
affected_tables = ['attendees', 'calendars', 'slots', 'subscribers'] | ||
index_tables = ['appointments', 'availabilities', 'external_connections', 'schedules', 'slots', ] | ||
|
||
def upgrade() -> None: | ||
for table in affected_tables: | ||
op.add_column(table, sa.Column('time_created', sa.DateTime, server_default=func.now(), index=True)) | ||
# Slots already has this column... | ||
if table != 'slots': | ||
op.add_column(table, sa.Column('time_updated', sa.DateTime, server_default=func.now(), index=True)) | ||
|
||
# Fix some existing time_* columns | ||
for table in index_tables: | ||
op.create_index('ix_time_created', table, ['time_created']) | ||
op.create_index('ix_time_updated', table, ['time_updated']) | ||
|
||
|
||
def downgrade() -> None: | ||
for table in affected_tables: | ||
op.drop_column(table, 'time_created') | ||
if table != 'slots': | ||
op.drop_column(table, 'time_updated') | ||
|
||
for table in index_tables: | ||
op.drop_index('ix_time_created', table) | ||
op.drop_index('ix_time_updated', table) |
24 changes: 24 additions & 0 deletions
24
backend/src/appointment/migrations/versions/2024_01_12_1801-ea551afc14fc_merge_commit.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,24 @@ | ||
"""Merge Commit | ||
Revision ID: ea551afc14fc | ||
Revises: ad7cc2de5ff8, 502c76bc79e0 | ||
Create Date: 2024-01-12 18:01:38.962773 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'ea551afc14fc' | ||
down_revision = ('ad7cc2de5ff8', '502c76bc79e0') | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
pass | ||
|
||
|
||
def downgrade() -> None: | ||
pass |