-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Computational backend: connect to resource tracking via RabbitMQ (🗃️,
⚠️ ) (#4570)
- Loading branch information
Showing
46 changed files
with
1,701 additions
and
379 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
76 changes: 76 additions & 0 deletions
76
...src/simcore_postgres_database/migration/versions/6da4357ce10f_add_heartbeat_timestamps.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,76 @@ | ||
"""add heartbeat timestamps | ||
Revision ID: 6da4357ce10f | ||
Revises: 9b33ef4c690a | ||
Create Date: 2023-08-07 06:31:14.681513+00:00 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "6da4357ce10f" | ||
down_revision = "9b33ef4c690a" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
modified_timestamp_trigger = sa.DDL( | ||
""" | ||
DROP TRIGGER IF EXISTS trigger_auto_update on comp_tasks; | ||
CREATE TRIGGER trigger_auto_update | ||
BEFORE INSERT OR UPDATE ON comp_tasks | ||
FOR EACH ROW EXECUTE PROCEDURE comp_tasks_auto_update_modified(); | ||
""" | ||
) | ||
|
||
update_modified_timestamp_procedure = sa.DDL( | ||
""" | ||
CREATE OR REPLACE FUNCTION comp_tasks_auto_update_modified() | ||
RETURNS TRIGGER AS $$ | ||
BEGIN | ||
NEW.modified := current_timestamp; | ||
RETURN NEW; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
""" | ||
) | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"comp_tasks", | ||
sa.Column("last_heartbeat", sa.DateTime(timezone=True), nullable=True), | ||
) | ||
op.add_column( | ||
"comp_tasks", | ||
sa.Column( | ||
"created", | ||
sa.DateTime(timezone=True), | ||
server_default=sa.text("now()"), | ||
nullable=False, | ||
), | ||
) | ||
op.add_column( | ||
"comp_tasks", | ||
sa.Column( | ||
"modified", | ||
sa.DateTime(timezone=True), | ||
server_default=sa.text("now()"), | ||
nullable=False, | ||
), | ||
) | ||
# ### end Alembic commands ### | ||
op.execute(update_modified_timestamp_procedure) | ||
op.execute(modified_timestamp_trigger) | ||
|
||
|
||
def downgrade(): | ||
op.execute(sa.DDL("DROP TRIGGER IF EXISTS trigger_auto_update on comp_tasks;")) | ||
op.execute(sa.DDL("DROP FUNCTION comp_tasks_auto_update_modified();")) | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("comp_tasks", "modified") | ||
op.drop_column("comp_tasks", "created") | ||
op.drop_column("comp_tasks", "last_heartbeat") | ||
# ### 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
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ services: | |
volumes: | ||
postgres_data: | ||
name: ${POSTGRES_DATA_VOLUME} | ||
external: true |
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.