-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Setup Initial Migrations with Alembic
- Loading branch information
1 parent
1de6fd3
commit db0d016
Showing
11 changed files
with
281 additions
and
307 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
45 changes: 0 additions & 45 deletions
45
backend/alembic/versions/20240911__38a0365a40fd__create_devices.py
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
backend/alembic/versions/20240912__9b835b4d8801__alter_tasks_table.py
This file was deleted.
Oops, something went wrong.
63 changes: 0 additions & 63 deletions
63
backend/alembic/versions/20240913__dcb77f1319fd__create_quantum_gates_table.py
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
backend/alembic/versions/20241227__4259239bd704__create_tables.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,63 @@ | ||
"""create_tables | ||
Revision ID: 4259239bd704 | ||
Revises: | ||
Create Date: 2024-12-27 15:53:59.225458 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = '4259239bd704' | ||
down_revision: Union[str, None] = None | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('devices', | ||
sa.Column('id', sa.String(length=64), nullable=False), | ||
sa.Column('device_type', sa.String(length=64), nullable=False), | ||
sa.Column('status', sa.String(length=64), nullable=False), | ||
sa.Column('available_at', sa.DateTime(), nullable=True), | ||
sa.Column('pending_jobs', sa.Integer(), nullable=False), | ||
sa.Column('n_qubits', sa.Integer(), nullable=False), | ||
sa.Column('basis_gates', sa.String(length=256), nullable=False), | ||
sa.Column('instructions', sa.String(length=64), nullable=False), | ||
sa.Column('device_info', sa.Text(), nullable=False), | ||
sa.Column('calibrated_at', sa.DateTime(), nullable=False), | ||
sa.Column('description', sa.String(length=128), nullable=False), | ||
sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), | ||
sa.Column('updated_at', sa.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=True), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_table('jobs', | ||
sa.Column('id', sa.String(length=64), nullable=False), | ||
sa.Column('owner', sa.String(length=64), nullable=False), | ||
sa.Column('name', sa.String(length=256), nullable=True), | ||
sa.Column('description', sa.String(length=1024), nullable=True), | ||
sa.Column('device_id', sa.String(length=64), nullable=False), | ||
sa.Column('job_info', sa.Text(), nullable=False), | ||
sa.Column('transpiler_info', sa.Text(), nullable=False), | ||
sa.Column('simulator_info', sa.Text(), nullable=False), | ||
sa.Column('mitigation_info', sa.Text(), nullable=False), | ||
sa.Column('job_type', sa.String(length=64), nullable=False), | ||
sa.Column('shots', sa.Integer(), nullable=True), | ||
sa.Column('status', sa.String(length=32), nullable=False), | ||
sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), | ||
sa.Column('updated_at', sa.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=True), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('jobs') | ||
op.drop_table('devices') | ||
# ### end Alembic commands ### |
43 changes: 43 additions & 0 deletions
43
backend/alembic/versions/20241227__6bd5dd2dc2ce__set_jobs_status_default.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 @@ | ||
"""set_jobs_status_default | ||
Revision ID: 6bd5dd2dc2ce | ||
Revises: 4259239bd704 | ||
Create Date: 2024-12-27 15:56:56.786646 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects import mysql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "6bd5dd2dc2ce" | ||
down_revision: Union[str, None] = "4259239bd704" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.alter_column( | ||
"jobs", | ||
"status", | ||
existing_type=mysql.VARCHAR(collation="utf8mb4_unicode_ci", length=32), | ||
server_default="submitted", | ||
existing_nullable=False, | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.alter_column( | ||
"jobs", | ||
"status", | ||
existing_type=mysql.VARCHAR(collation="utf8mb4_unicode_ci", length=32), | ||
server_default=None, | ||
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 |
---|---|---|
@@ -1,7 +1,16 @@ | ||
# Don't erase this definition, it is used to import all models in the api.models package | ||
# https://stackoverflow.com/questions/7478403/sqlalchemy-classes-across-files | ||
# if table has foreign key, it should be imported in the same file | ||
__all__ = ["Device", "Job", "Base"] | ||
__all__ = [ | ||
"Base", | ||
"DeviceId", | ||
"DeviceStatus", | ||
"Device", | ||
"JobId", | ||
"Job", | ||
"JobStatus", | ||
"Base", | ||
] | ||
from oqtopus_cloud.common.models.base import Base | ||
from oqtopus_cloud.common.models.device import Device | ||
from oqtopus_cloud.common.models.job import Job | ||
from oqtopus_cloud.common.models.device import Device, DeviceId, DeviceStatus | ||
from oqtopus_cloud.common.models.job import Job, JobId, JobStatus |
Oops, something went wrong.