avoid broken migrations that get dropped in later migration

This commit is contained in:
stvnrlly
2023-02-17 11:02:58 -05:00
parent 518e2264a6
commit da545f9a67
4 changed files with 72 additions and 71 deletions

View File

@@ -37,28 +37,28 @@ 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.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('letter_rates', [
{
'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('letter_rates', [
# {
# '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']
# )
# ])
def downgrade():

View File

@@ -29,22 +29,23 @@ def upgrade():
4 sheets - £1.08
5 sheets - £1.16
"""
op.bulk_insert('letter_rates', [
{
'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('letter_rates', [
# {
# '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():

View File

@@ -34,24 +34,24 @@ 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.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE)
op.bulk_insert('letter_rates', [
{
'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('letter_rates', [
# {
# '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']
# )
# ])
def downgrade():
# Make sure you've thought about billing implications etc before downgrading!

View File

@@ -34,24 +34,24 @@ 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.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE)
op.bulk_insert('letter_rates', [
{
'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('letter_rates', [
# {
# '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']
# )
# ])
def downgrade():