mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 20:59:05 +00:00
Make sure room names are unique
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
from logging.config import fileConfig
|
||||
from reflector.settings import settings
|
||||
from reflector.db import metadata
|
||||
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy import pool
|
||||
|
||||
from alembic import context
|
||||
from reflector.db import metadata
|
||||
from reflector.settings import settings
|
||||
from sqlalchemy import engine_from_config, pool
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
@@ -45,6 +43,7 @@ def run_migrations_offline() -> None:
|
||||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"},
|
||||
render_as_batch=True,
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
@@ -67,7 +66,9 @@ def run_migrations_online() -> None:
|
||||
)
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(connection=connection, target_metadata=target_metadata)
|
||||
context.configure(
|
||||
connection=connection, target_metadata=target_metadata, render_as_batch=True
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
34
server/migrations/versions/0925da921477_unique_room_names.py
Normal file
34
server/migrations/versions/0925da921477_unique_room_names.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""Unique room names
|
||||
|
||||
Revision ID: 0925da921477
|
||||
Revises: 764ce6db4388
|
||||
Create Date: 2024-09-24 16:12:56.944133
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "0925da921477"
|
||||
down_revision: Union[str, None] = "764ce6db4388"
|
||||
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! ###
|
||||
with op.batch_alter_table("room", schema=None) as batch_op:
|
||||
batch_op.create_unique_constraint("uq_room_name", ["name"])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("room", schema=None) as batch_op:
|
||||
batch_op.drop_constraint("uq_room_name", type_="unique")
|
||||
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user