Skip to content

Saleor Core: the high performance, composable, headless commerce API.

drop unused fields from Voucher (used, code) and VoucherCustomer (voucher_id) (#15016)

Michał Macioszczyk20348ff85029
diff --git a/saleor/discount/migrations/0071_auto_20231213_1413.py b/saleor/discount/migrations/0071_auto_20231213_1413.py
new file mode 100644
index 0000000000..9713219421
--- /dev/null
+++ b/saleor/discount/migrations/0071_auto_20231213_1413.py
@@ -0,0 +1,25 @@
+# Generated by Django 3.2.23 on 2023-12-13 14:13
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ atomic = False
+
+ dependencies = [
+ ("discount", "0070_alter_promotion_options"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ sql="""
+ DROP INDEX CONCURRENTLY
+ IF EXISTS discount_vouchercustomer_voucher_id_bb55c04f;
+ """,
+ reverse_sql="""
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS
+ discount_vouchercustomer_voucher_id_bb55c04f ON
+ discount_vouchercustomer(voucher_id);
+ """,
+ )
+ ]
diff --git a/saleor/discount/migrations/0072_auto_20231213_1535.py b/saleor/discount/migrations/0072_auto_20231213_1535.py
new file mode 100644
index 0000000000..cc8b0ce859
--- /dev/null
+++ b/saleor/discount/migrations/0072_auto_20231213_1535.py
@@ -0,0 +1,31 @@
+# Generated by Django 3.2.23 on 2023-12-13 15:35
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("discount", "0071_auto_20231213_1413"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ sql="""
+ ALTER TABLE discount_vouchercustomer DROP CONSTRAINT IF EXISTS
+ discount_vouchercust_voucher_id_bb55c04f_fk_discount_;
+ ALTER TABLE discount_vouchercustomer
+ DROP COLUMN voucher_id;
+ ALTER TABLE discount_voucher DROP COLUMN code;
+ ALTER TABLE discount_voucher DROP COLUMN used;
+ """,
+ reverse_sql="""
+ ALTER TABLE discount_vouchercustomer ADD COLUMN voucher_id integer;
+ ALTER TABLE discount_vouchercustomer
+ ADD CONSTRAINT discount_vouchercust_voucher_id_bb55c04f_fk_discount_
+ FOREIGN KEY (voucher_id) REFERENCES
+ discount_voucher(id) DEFERRABLE INITIALLY DEFERRED;
+ ALTER TABLE discount_voucher ADD COLUMN code varchar(255);
+ ALTER TABLE discount_voucher ADD COLUMN used integer DEFAULT 0;
+ """,
+ )
+ ]