From 87a154bd0afc4632a91bca918dd2be8846f93287 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 1 Jul 2020 00:47:59 +0530 Subject: [PATCH 1/3] Create migration --- .../migrations/0060_update_DE_vat_covid-19.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 hosting/migrations/0060_update_DE_vat_covid-19.py diff --git a/hosting/migrations/0060_update_DE_vat_covid-19.py b/hosting/migrations/0060_update_DE_vat_covid-19.py new file mode 100644 index 00000000..a551720e --- /dev/null +++ b/hosting/migrations/0060_update_DE_vat_covid-19.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2020-06-30 19:12 + +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0059_stripetaxrate'), + ] + + operations = [ + migrations.RunSQL( + "update hosting_vatrates set stop_date = '2020-06-30' where territory_codes = 'DE' and rate = '0.19'", + "insert into hosting_vatrates (start_date, stop_date, territory_codes, currency_code, rate, rate_type, description) values ('2020-07-01',null,'DE', 'EUR', '0.16', 'standard', 'Germany (member state) standard VAT rate - COVID 19 reduced rate')", + "update hosting_stripetaxrate set description = 'VAT for DE pre-COVID-19' where description = 'VAT for DE'" + + ) + ] From 58377319b96ef1fa15680f0ad60e981644fd42aa Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 1 Jul 2020 01:18:57 +0530 Subject: [PATCH 2/3] Make migration reversible --- .../migrations/0060_update_DE_vat_covid-19.py | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hosting/migrations/0060_update_DE_vat_covid-19.py b/hosting/migrations/0060_update_DE_vat_covid-19.py index a551720e..2fd8418e 100644 --- a/hosting/migrations/0060_update_DE_vat_covid-19.py +++ b/hosting/migrations/0060_update_DE_vat_covid-19.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.9.4 on 2020-06-30 19:12 - from __future__ import unicode_literals from django.db import migrations @@ -14,9 +13,21 @@ class Migration(migrations.Migration): operations = [ migrations.RunSQL( - "update hosting_vatrates set stop_date = '2020-06-30' where territory_codes = 'DE' and rate = '0.19'", - "insert into hosting_vatrates (start_date, stop_date, territory_codes, currency_code, rate, rate_type, description) values ('2020-07-01',null,'DE', 'EUR', '0.16', 'standard', 'Germany (member state) standard VAT rate - COVID 19 reduced rate')", - "update hosting_stripetaxrate set description = 'VAT for DE pre-COVID-19' where description = 'VAT for DE'" + sql=["update hosting_vatrates set stop_date = '2020-06-30' where territory_codes = 'DE' and rate = '0.19'"], + reverse_sql=[ + "update hosting_vatrates set stop_date = '' where stop_date = '2020-06-30' and territory_codes = 'DE' and rate = '0.19'"], + ), + migrations.RunSQL( + sql=[ + "insert into hosting_vatrates (start_date, stop_date, territory_codes, currency_code, rate, rate_type, description) values ('2020-07-01',null,'DE', 'EUR', '0.16', 'standard', 'Germany (member state) standard VAT rate - COVID 19 reduced rate')"], + reverse_sql=[ + "delete from hosting_vatrates where description = 'Germany (member state) standard VAT rate - COVID 19 reduced rate' and start_date = '2020-07-01' and territory_codes = 'DE'" ], + ), - ) + migrations.RunSQL( + sql=[ + "update hosting_stripetaxrate set description = 'VAT for DE pre-COVID-19' where description = 'VAT for DE'"], + reverse_sql=[ + "update hosting_stripetaxrate set description = 'VAT for DE' where description = 'VAT for DE pre-COVID-19'"], + ), ] From c339c19cfd1e78e326b983183d421442ccc83ee3 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 1 Jul 2020 01:21:57 +0530 Subject: [PATCH 3/3] Fix date format bug --- hosting/migrations/0060_update_DE_vat_covid-19.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosting/migrations/0060_update_DE_vat_covid-19.py b/hosting/migrations/0060_update_DE_vat_covid-19.py index 2fd8418e..17c6394b 100644 --- a/hosting/migrations/0060_update_DE_vat_covid-19.py +++ b/hosting/migrations/0060_update_DE_vat_covid-19.py @@ -15,7 +15,7 @@ class Migration(migrations.Migration): migrations.RunSQL( sql=["update hosting_vatrates set stop_date = '2020-06-30' where territory_codes = 'DE' and rate = '0.19'"], reverse_sql=[ - "update hosting_vatrates set stop_date = '' where stop_date = '2020-06-30' and territory_codes = 'DE' and rate = '0.19'"], + "update hosting_vatrates set stop_date = null where stop_date = '2020-06-30' and territory_codes = 'DE' and rate = '0.19'"], ), migrations.RunSQL( sql=[