remove crown stuff

This commit is contained in:
stvnrlly
2022-10-17 20:16:39 +00:00
parent 59732ce137
commit 3fff0fdd84
22 changed files with 168 additions and 195 deletions

View File

@@ -38,33 +38,37 @@ CHANGEOVER_DATE = datetime(2019, 9, 30, 23, 0)
def upgrade():
# all old rates are going in the bin
conn = op.get_bind()
conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE)
# conn = op.get_bind()
# conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE)
base_prices = {
'second': 30,
'first': 56,
}
op.bulk_insert(LetterRate.__table__, [
{
'id': uuid.uuid4(),
'start_date': CHANGEOVER_DATE,
'end_date': None,
'sheet_count': sheet_count,
'rate': (base_prices[post_class] + (5 * sheet_count)) / 100.0,
'crown': crown,
'post_class': post_class,
}
for sheet_count, crown, post_class in itertools.product(
range(1, 6),
[True, False],
['first', 'second']
)
])
# base_prices = {
# 'second': 30,
# 'first': 56,
# }
# op.bulk_insert(LetterRate.__table__, [
# {
# 'id': uuid.uuid4(),
# 'start_date': CHANGEOVER_DATE,
# 'end_date': None,
# 'sheet_count': sheet_count,
# 'rate': (base_prices[post_class] + (5 * sheet_count)) / 100.0,
# 'crown': crown,
# 'post_class': post_class,
# }
# for sheet_count, crown, post_class in itertools.product(
# range(1, 6),
# [True, False],
# ['first', 'second']
# )
# ])
pass
def downgrade():
# Make sure you've thought about billing implications etc before downgrading!
conn = op.get_bind()
conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE)
conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE)
# conn = op.get_bind()
# conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE)
# conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE)
pass

View File

@@ -31,24 +31,28 @@ def upgrade():
4 sheets - £1.08
5 sheets - £1.16
"""
op.bulk_insert(LetterRate.__table__, [
{
'id': uuid.uuid4(),
'start_date': start_date,
'end_date': None,
'sheet_count': sheet_count,
'rate': (base_rate + (8 * sheet_count)) / 100.0,
'crown': crown,
'post_class': post_class,
}
for sheet_count, crown, post_class in itertools.product(
range(1, 6),
[True, False],
['europe', 'rest-of-world']
)
])
# op.bulk_insert(LetterRate.__table__, [
# {
# 'id': uuid.uuid4(),
# 'start_date': start_date,
# 'end_date': None,
# 'sheet_count': sheet_count,
# 'rate': (base_rate + (8 * sheet_count)) / 100.0,
# 'crown': crown,
# 'post_class': post_class,
# }
# for sheet_count, crown, post_class in itertools.product(
# range(1, 6),
# [True, False],
# ['europe', 'rest-of-world']
# )
# ])
pass
def downgrade():
conn = op.get_bind()
conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=start_date)
# conn = op.get_bind()
# conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=start_date)
pass

View File

@@ -35,28 +35,32 @@ def get_new_rate(sheet_count, post_class):
def upgrade():
conn = op.get_bind()
conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE)
# conn = op.get_bind()
# conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE)
op.bulk_insert(LetterRate.__table__, [
{
'id': uuid.uuid4(),
'start_date': CHANGEOVER_DATE,
'end_date': None,
'sheet_count': sheet_count,
'rate': get_new_rate(sheet_count, post_class),
'crown': crown,
'post_class': post_class,
}
for sheet_count, crown, post_class in itertools.product(
range(1, 6),
[True, False],
['first', 'second', 'europe', 'rest-of-world']
)
])
# op.bulk_insert(LetterRate.__table__, [
# {
# 'id': uuid.uuid4(),
# 'start_date': CHANGEOVER_DATE,
# 'end_date': None,
# 'sheet_count': sheet_count,
# 'rate': get_new_rate(sheet_count, post_class),
# 'crown': crown,
# 'post_class': post_class,
# }
# for sheet_count, crown, post_class in itertools.product(
# range(1, 6),
# [True, False],
# ['first', 'second', 'europe', 'rest-of-world']
# )
# ])
pass
def downgrade():
# Make sure you've thought about billing implications etc before downgrading!
conn = op.get_bind()
conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE)
conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE)
# conn = op.get_bind()
# conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE)
# conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE)
pass

View File

@@ -35,29 +35,33 @@ def get_new_rate(sheet_count, post_class):
def upgrade():
conn = op.get_bind()
conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE)
# conn = op.get_bind()
# conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE)
op.bulk_insert(LetterRate.__table__, [
{
'id': uuid.uuid4(),
'start_date': CHANGEOVER_DATE,
'end_date': None,
'sheet_count': sheet_count,
'rate': get_new_rate(sheet_count, post_class),
'crown': crown,
'post_class': post_class,
}
for sheet_count, crown, post_class in itertools.product(
range(1, 6),
[True, False],
['first', 'second', 'europe', 'rest-of-world']
)
])
# op.bulk_insert(LetterRate.__table__, [
# {
# 'id': uuid.uuid4(),
# 'start_date': CHANGEOVER_DATE,
# 'end_date': None,
# 'sheet_count': sheet_count,
# 'rate': get_new_rate(sheet_count, post_class),
# 'crown': crown,
# 'post_class': post_class,
# }
# for sheet_count, crown, post_class in itertools.product(
# range(1, 6),
# [True, False],
# ['first', 'second', 'europe', 'rest-of-world']
# )
# ])
pass
def downgrade():
# Make sure you've thought about billing implications etc before downgrading!
conn = op.get_bind()
conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE)
conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE)
# conn = op.get_bind()
# conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE)
# conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE)
pass

View File

@@ -0,0 +1,33 @@
"""
Revision ID: 0379_remove_crown
Revises: 0378_add_org_names
Create Date: 2022-10-17 17:05:07.193377
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = '0379_remove_crown'
down_revision = '0378_add_org_names'
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('letter_rates', 'crown')
op.drop_column('organisation', 'crown')
op.drop_column('organisation_types', 'is_crown')
op.drop_column('services', 'crown')
op.drop_column('services_history', 'crown')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('services_history', sa.Column('crown', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.add_column('services', sa.Column('crown', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.add_column('organisation_types', sa.Column('is_crown', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.add_column('organisation', sa.Column('crown', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.add_column('letter_rates', sa.Column('crown', sa.BOOLEAN(), autoincrement=False, nullable=False))
# ### end Alembic commands ###