Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add database migration that adds parameter fields to deployment schedules #16947

Merged
merged 4 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/prefect/server/database/_migrations/MIGRATION-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Each time a database migration is written, an entry is included here with:

This gives us a history of changes and will create merge conflicts if two migrations are made at once, flagging situations where a branch needs to be updated before merging.

# Add parameters column to deployment schedules
SQLite: `67f886da208e`
Postgres: `c163acd7e8e3`

# Bring ORM models and migrations back in sync
SQLite: `a49711513ad4`
Postgres: `5d03c01be85e`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Add parameters column to deployment schedules

Revision ID: c163acd7e8e3
Revises: 5d03c01be85e
Create Date: 2025-02-03 12:51:46.641928

"""

import sqlalchemy as sa
from alembic import op

import prefect

# revision identifiers, used by Alembic.
revision = "c163acd7e8e3"
down_revision = "5d03c01be85e"
branch_labels = None
depends_on = None


def upgrade():
op.add_column(
"deployment_schedule",
sa.Column(
"parameters",
prefect.server.utilities.database.JSON,
server_default="{}",
nullable=False,
),
)


def downgrade():
op.drop_column("deployment_schedule", "parameters")
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Add parameters column to deployment schedules

Revision ID: 67f886da208e
Revises: a49711513ad4
Create Date: 2025-02-03 12:52:28.370958

"""

import sqlalchemy as sa
from alembic import op

import prefect

# revision identifiers, used by Alembic.
revision = "67f886da208e"
down_revision = "a49711513ad4"
branch_labels = None
depends_on = None


def upgrade():
op.add_column(
"deployment_schedule",
sa.Column(
"parameters",
prefect.server.utilities.database.JSON,
server_default="{}",
nullable=False,
),
)


def downgrade():
op.drop_column("deployment_schedule", "parameters")
3 changes: 3 additions & 0 deletions src/prefect/server/database/orm_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,9 @@ class DeploymentSchedule(Base):
)
active: Mapped[bool] = mapped_column(default=True)
max_scheduled_runs: Mapped[Optional[int]]
parameters: Mapped[dict[str, Any]] = mapped_column(
JSON, server_default="{}", default=dict, nullable=False
)


class Deployment(Base):
Expand Down