Fix: Username unique index was case sensitive and this allowed duplicate names.
Feature: Moved temporal products into their own module and reverted the products module
This commit is contained in:
@ -0,0 +1,46 @@
|
||||
"""temporal products fixed
|
||||
|
||||
Revision ID: 0e326930b8a4
|
||||
Revises: 3609c44430c8
|
||||
Create Date: 2021-10-22 09:36:11.746119
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy import column, func, table, text
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "0e326930b8a4"
|
||||
down_revision = "3609c44430c8"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_unique_constraint(op.f("uq_vouchers_bill_id"), "vouchers", ["bill_id", "voucher_type"])
|
||||
|
||||
prod = table(
|
||||
"product_versions",
|
||||
column("id", postgresql.UUID(as_uuid=True)),
|
||||
column("product_id", postgresql.UUID(as_uuid=True)),
|
||||
column("valid_from", sa.Date()),
|
||||
column("valid_till", sa.Date()),
|
||||
)
|
||||
|
||||
op.create_exclude_constraint(
|
||||
"uq_product_versions_product_id",
|
||||
"product_versions",
|
||||
(prod.c.product_id, "="),
|
||||
(func.daterange(prod.c.valid_from, prod.c.valid_till, text("'[]'")), "&&"),
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(op.f("uq_vouchers_bill_id"), "vouchers", type_="unique")
|
||||
# ### end Alembic commands ###
|
||||
31
barker/alembic/versions/3609c44430c8_user.py
Normal file
31
barker/alembic/versions/3609c44430c8_user.py
Normal file
@ -0,0 +1,31 @@
|
||||
"""user
|
||||
|
||||
Revision ID: 3609c44430c8
|
||||
Revises: 81d94c5223a7
|
||||
Create Date: 2021-09-28 09:18:10.666701
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "3609c44430c8"
|
||||
down_revision = "81d94c5223a7"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint("uq_users_name", "users", type_="unique")
|
||||
op.create_index("uq_users_name", "users", [sa.text("lower(name)")], unique=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index("uq_users_name", table_name="users")
|
||||
op.create_unique_constraint("uq_users_name", "users", ["name"])
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user