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:
2021-10-27 09:27:47 +05:30
parent debe0df7b7
commit 124cf4d9ff
40 changed files with 1522 additions and 313 deletions

View File

@ -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 ###

View 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 ###