feat(core-flows,pricing,medusa,pricing,types,utils): Price List Prices can have their own rules (#5752)
**What** - Add price-rules for prices in price-lists - make rules object optional when creating prices **Why** - more price granularity Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
This commit is contained in:
co-authored by
Philip Korsholm
parent
f05c20695e
commit
079f0da83f
@@ -1,7 +1,5 @@
|
||||
{
|
||||
"namespaces": [
|
||||
"public"
|
||||
],
|
||||
"namespaces": ["public"],
|
||||
"name": "public",
|
||||
"tables": [
|
||||
{
|
||||
@@ -48,9 +46,7 @@
|
||||
"indexes": [
|
||||
{
|
||||
"keyName": "currency_pkey",
|
||||
"columnNames": [
|
||||
"code"
|
||||
],
|
||||
"columnNames": ["code"],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
@@ -143,18 +139,14 @@
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"columnNames": [
|
||||
"currency_code"
|
||||
],
|
||||
"columnNames": ["currency_code"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_money_amount_currency_code",
|
||||
"primary": false,
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"columnNames": [
|
||||
"deleted_at"
|
||||
],
|
||||
"columnNames": ["deleted_at"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_money_amount_deleted_at",
|
||||
"primary": false,
|
||||
@@ -162,9 +154,7 @@
|
||||
},
|
||||
{
|
||||
"keyName": "money_amount_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"columnNames": ["id"],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
@@ -174,13 +164,9 @@
|
||||
"foreignKeys": {
|
||||
"money_amount_currency_code_foreign": {
|
||||
"constraintName": "money_amount_currency_code_foreign",
|
||||
"columnNames": [
|
||||
"currency_code"
|
||||
],
|
||||
"columnNames": ["currency_code"],
|
||||
"localTableName": "public.money_amount",
|
||||
"referencedColumnNames": [
|
||||
"code"
|
||||
],
|
||||
"referencedColumnNames": ["code"],
|
||||
"referencedTableName": "public.currency",
|
||||
"deleteRule": "set null",
|
||||
"updateRule": "cascade"
|
||||
@@ -224,10 +210,7 @@
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"default": "'draft'",
|
||||
"enumItems": [
|
||||
"active",
|
||||
"draft"
|
||||
],
|
||||
"enumItems": ["active", "draft"],
|
||||
"mappedType": "enum"
|
||||
},
|
||||
"type": {
|
||||
@@ -238,10 +221,7 @@
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"default": "'sale'",
|
||||
"enumItems": [
|
||||
"sale",
|
||||
"override"
|
||||
],
|
||||
"enumItems": ["sale", "override"],
|
||||
"mappedType": "enum"
|
||||
},
|
||||
"starts_at": {
|
||||
@@ -264,8 +244,8 @@
|
||||
"length": 6,
|
||||
"mappedType": "datetime"
|
||||
},
|
||||
"number_rules": {
|
||||
"name": "number_rules",
|
||||
"rules_count": {
|
||||
"name": "rules_count",
|
||||
"type": "integer",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
@@ -311,9 +291,7 @@
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"columnNames": [
|
||||
"deleted_at"
|
||||
],
|
||||
"columnNames": ["deleted_at"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_list_deleted_at",
|
||||
"primary": false,
|
||||
@@ -321,9 +299,7 @@
|
||||
},
|
||||
{
|
||||
"keyName": "price_list_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"columnNames": ["id"],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
@@ -349,9 +325,7 @@
|
||||
"indexes": [
|
||||
{
|
||||
"keyName": "price_set_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"columnNames": ["id"],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
@@ -398,8 +372,8 @@
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"number_rules": {
|
||||
"name": "number_rules",
|
||||
"rules_count": {
|
||||
"name": "rules_count",
|
||||
"type": "integer",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
@@ -422,36 +396,28 @@
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"columnNames": [
|
||||
"price_set_id"
|
||||
],
|
||||
"columnNames": ["price_set_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_set_money_amount_price_set_id",
|
||||
"primary": false,
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"columnNames": [
|
||||
"money_amount_id"
|
||||
],
|
||||
"columnNames": ["money_amount_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_set_money_amount_money_amount_id",
|
||||
"primary": false,
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"columnNames": [
|
||||
"money_amount_id"
|
||||
],
|
||||
"columnNames": ["money_amount_id"],
|
||||
"composite": false,
|
||||
"keyName": "price_set_money_amount_money_amount_id_unique",
|
||||
"primary": false,
|
||||
"unique": true
|
||||
},
|
||||
{
|
||||
"columnNames": [
|
||||
"price_list_id"
|
||||
],
|
||||
"columnNames": ["price_list_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_rule_price_list_id",
|
||||
"primary": false,
|
||||
@@ -459,9 +425,7 @@
|
||||
},
|
||||
{
|
||||
"keyName": "price_set_money_amount_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"columnNames": ["id"],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
@@ -471,39 +435,27 @@
|
||||
"foreignKeys": {
|
||||
"price_set_money_amount_price_set_id_foreign": {
|
||||
"constraintName": "price_set_money_amount_price_set_id_foreign",
|
||||
"columnNames": [
|
||||
"price_set_id"
|
||||
],
|
||||
"columnNames": ["price_set_id"],
|
||||
"localTableName": "public.price_set_money_amount",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.price_set",
|
||||
"deleteRule": "cascade",
|
||||
"updateRule": "cascade"
|
||||
},
|
||||
"price_set_money_amount_money_amount_id_foreign": {
|
||||
"constraintName": "price_set_money_amount_money_amount_id_foreign",
|
||||
"columnNames": [
|
||||
"money_amount_id"
|
||||
],
|
||||
"columnNames": ["money_amount_id"],
|
||||
"localTableName": "public.price_set_money_amount",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.money_amount",
|
||||
"deleteRule": "cascade",
|
||||
"updateRule": "cascade"
|
||||
},
|
||||
"price_set_money_amount_price_list_id_foreign": {
|
||||
"constraintName": "price_set_money_amount_price_list_id_foreign",
|
||||
"columnNames": [
|
||||
"price_list_id"
|
||||
],
|
||||
"columnNames": ["price_list_id"],
|
||||
"localTableName": "public.price_set_money_amount",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.price_list",
|
||||
"deleteRule": "cascade",
|
||||
"updateRule": "cascade"
|
||||
@@ -554,9 +506,7 @@
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"columnNames": [
|
||||
"rule_attribute"
|
||||
],
|
||||
"columnNames": ["rule_attribute"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_rule_type_rule_attribute",
|
||||
"primary": false,
|
||||
@@ -564,9 +514,7 @@
|
||||
},
|
||||
{
|
||||
"keyName": "rule_type_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"columnNames": ["id"],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
@@ -609,18 +557,14 @@
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"columnNames": [
|
||||
"price_set_id"
|
||||
],
|
||||
"columnNames": ["price_set_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_set_rule_type_price_set_id",
|
||||
"primary": false,
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"columnNames": [
|
||||
"rule_type_id"
|
||||
],
|
||||
"columnNames": ["rule_type_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_set_rule_type_rule_type_id",
|
||||
"primary": false,
|
||||
@@ -628,9 +572,7 @@
|
||||
},
|
||||
{
|
||||
"keyName": "price_set_rule_type_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"columnNames": ["id"],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
@@ -640,26 +582,18 @@
|
||||
"foreignKeys": {
|
||||
"price_set_rule_type_price_set_id_foreign": {
|
||||
"constraintName": "price_set_rule_type_price_set_id_foreign",
|
||||
"columnNames": [
|
||||
"price_set_id"
|
||||
],
|
||||
"columnNames": ["price_set_id"],
|
||||
"localTableName": "public.price_set_rule_type",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.price_set",
|
||||
"deleteRule": "cascade",
|
||||
"updateRule": "cascade"
|
||||
},
|
||||
"price_set_rule_type_rule_type_id_foreign": {
|
||||
"constraintName": "price_set_rule_type_rule_type_id_foreign",
|
||||
"columnNames": [
|
||||
"rule_type_id"
|
||||
],
|
||||
"columnNames": ["rule_type_id"],
|
||||
"localTableName": "public.price_set_rule_type",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.rule_type",
|
||||
"updateRule": "cascade"
|
||||
}
|
||||
@@ -708,18 +642,14 @@
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"columnNames": [
|
||||
"price_set_money_amount_id"
|
||||
],
|
||||
"columnNames": ["price_set_money_amount_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_set_money_amount_rules_price_set_money_amount_id",
|
||||
"primary": false,
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"columnNames": [
|
||||
"rule_type_id"
|
||||
],
|
||||
"columnNames": ["rule_type_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_set_money_amount_rules_rule_type_id",
|
||||
"primary": false,
|
||||
@@ -727,9 +657,7 @@
|
||||
},
|
||||
{
|
||||
"keyName": "price_set_money_amount_rules_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"columnNames": ["id"],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
@@ -739,26 +667,18 @@
|
||||
"foreignKeys": {
|
||||
"price_set_money_amount_rules_price_set_money_amount_id_foreign": {
|
||||
"constraintName": "price_set_money_amount_rules_price_set_money_amount_id_foreign",
|
||||
"columnNames": [
|
||||
"price_set_money_amount_id"
|
||||
],
|
||||
"columnNames": ["price_set_money_amount_id"],
|
||||
"localTableName": "public.price_set_money_amount_rules",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.price_set_money_amount",
|
||||
"deleteRule": "cascade",
|
||||
"updateRule": "cascade"
|
||||
},
|
||||
"price_set_money_amount_rules_rule_type_id_foreign": {
|
||||
"constraintName": "price_set_money_amount_rules_rule_type_id_foreign",
|
||||
"columnNames": [
|
||||
"rule_type_id"
|
||||
],
|
||||
"columnNames": ["rule_type_id"],
|
||||
"localTableName": "public.price_set_money_amount_rules",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.rule_type",
|
||||
"updateRule": "cascade"
|
||||
}
|
||||
@@ -836,27 +756,21 @@
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"columnNames": [
|
||||
"price_set_id"
|
||||
],
|
||||
"columnNames": ["price_set_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_rule_price_set_id",
|
||||
"primary": false,
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"columnNames": [
|
||||
"rule_type_id"
|
||||
],
|
||||
"columnNames": ["rule_type_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_rule_rule_type_id",
|
||||
"primary": false,
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"columnNames": [
|
||||
"price_set_money_amount_id"
|
||||
],
|
||||
"columnNames": ["price_set_money_amount_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_rule_price_set_money_amount_id",
|
||||
"primary": false,
|
||||
@@ -864,9 +778,7 @@
|
||||
},
|
||||
{
|
||||
"keyName": "price_rule_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"columnNames": ["id"],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
@@ -876,38 +788,26 @@
|
||||
"foreignKeys": {
|
||||
"price_rule_price_set_id_foreign": {
|
||||
"constraintName": "price_rule_price_set_id_foreign",
|
||||
"columnNames": [
|
||||
"price_set_id"
|
||||
],
|
||||
"columnNames": ["price_set_id"],
|
||||
"localTableName": "public.price_rule",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.price_set",
|
||||
"deleteRule": "cascade",
|
||||
"updateRule": "cascade"
|
||||
},
|
||||
"price_rule_rule_type_id_foreign": {
|
||||
"constraintName": "price_rule_rule_type_id_foreign",
|
||||
"columnNames": [
|
||||
"rule_type_id"
|
||||
],
|
||||
"columnNames": ["rule_type_id"],
|
||||
"localTableName": "public.price_rule",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.rule_type",
|
||||
"updateRule": "cascade"
|
||||
},
|
||||
"price_rule_price_set_money_amount_id_foreign": {
|
||||
"constraintName": "price_rule_price_set_money_amount_id_foreign",
|
||||
"columnNames": [
|
||||
"price_set_money_amount_id"
|
||||
],
|
||||
"columnNames": ["price_set_money_amount_id"],
|
||||
"localTableName": "public.price_rule",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.price_set_money_amount",
|
||||
"deleteRule": "cascade",
|
||||
"updateRule": "cascade"
|
||||
@@ -948,18 +848,14 @@
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"columnNames": [
|
||||
"rule_type_id"
|
||||
],
|
||||
"columnNames": ["rule_type_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_list_rule_rule_type_id",
|
||||
"primary": false,
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"columnNames": [
|
||||
"price_list_id"
|
||||
],
|
||||
"columnNames": ["price_list_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_list_rule_price_list_id",
|
||||
"primary": false,
|
||||
@@ -967,19 +863,14 @@
|
||||
},
|
||||
{
|
||||
"keyName": "IDX_price_list_rule_rule_type_id_price_list_id_unique",
|
||||
"columnNames": [
|
||||
"price_list_id",
|
||||
"rule_type_id"
|
||||
],
|
||||
"columnNames": ["price_list_id", "rule_type_id"],
|
||||
"composite": true,
|
||||
"primary": false,
|
||||
"unique": true
|
||||
},
|
||||
{
|
||||
"keyName": "price_list_rule_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"columnNames": ["id"],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
@@ -989,25 +880,17 @@
|
||||
"foreignKeys": {
|
||||
"price_list_rule_rule_type_id_foreign": {
|
||||
"constraintName": "price_list_rule_rule_type_id_foreign",
|
||||
"columnNames": [
|
||||
"rule_type_id"
|
||||
],
|
||||
"columnNames": ["rule_type_id"],
|
||||
"localTableName": "public.price_list_rule",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.rule_type",
|
||||
"updateRule": "cascade"
|
||||
},
|
||||
"price_list_rule_price_list_id_foreign": {
|
||||
"constraintName": "price_list_rule_price_list_id_foreign",
|
||||
"columnNames": [
|
||||
"price_list_id"
|
||||
],
|
||||
"columnNames": ["price_list_id"],
|
||||
"localTableName": "public.price_list_rule",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.price_list",
|
||||
"updateRule": "cascade"
|
||||
}
|
||||
@@ -1047,9 +930,7 @@
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"columnNames": [
|
||||
"price_list_rule_id"
|
||||
],
|
||||
"columnNames": ["price_list_rule_id"],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_list_rule_price_list_rule_value_id",
|
||||
"primary": false,
|
||||
@@ -1057,9 +938,7 @@
|
||||
},
|
||||
{
|
||||
"keyName": "price_list_rule_value_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"columnNames": ["id"],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
@@ -1069,13 +948,9 @@
|
||||
"foreignKeys": {
|
||||
"price_list_rule_value_price_list_rule_id_foreign": {
|
||||
"constraintName": "price_list_rule_value_price_list_rule_id_foreign",
|
||||
"columnNames": [
|
||||
"price_list_rule_id"
|
||||
],
|
||||
"columnNames": ["price_list_rule_id"],
|
||||
"localTableName": "public.price_list_rule_value",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedColumnNames": ["id"],
|
||||
"referencedTableName": "public.price_list_rule",
|
||||
"deleteRule": "cascade",
|
||||
"updateRule": "cascade"
|
||||
|
||||
@@ -18,7 +18,7 @@ export class Migration20230929122253 extends Migration {
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'create table "price_set_money_amount" ("id" text not null, "title" text not null, "price_set_id" text not null, "money_amount_id" text not null, "number_rules" integer not null default 0, constraint "price_set_money_amount_pkey" primary key ("id"));'
|
||||
'create table "price_set_money_amount" ("id" text not null, "title" text not null, "price_set_id" text not null, "money_amount_id" text not null, "rules_count" integer not null default 0, constraint "price_set_money_amount_pkey" primary key ("id"));'
|
||||
)
|
||||
this.addSql(
|
||||
'create index "IDX_price_set_money_amount_price_set_id" on "price_set_money_amount" ("price_set_id");'
|
||||
@@ -103,7 +103,7 @@ export class Migration20230929122253 extends Migration {
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'create table if not exists "price_list" ("id" text not null, "status" text check ("status" in (\'active\', \'draft\')) not null default \'draft\', "starts_at" timestamptz null, "ends_at" timestamptz null, "number_rules" integer not null default 0, constraint "price_list_pkey" primary key ("id"));'
|
||||
'create table if not exists "price_list" ("id" text not null, "status" text check ("status" in (\'active\', \'draft\')) not null default \'draft\', "starts_at" timestamptz null, "ends_at" timestamptz null, "rules_count" integer not null default 0, constraint "price_list_pkey" primary key ("id"));'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
|
||||
@@ -15,7 +15,7 @@ export class Migration20231101232834 extends Migration {
|
||||
|
||||
this.addSql(
|
||||
`ALTER TABLE price_list
|
||||
ADD COLUMN IF NOT EXISTS number_rules integer not null default 0`
|
||||
ADD COLUMN IF NOT EXISTS rules_count integer not null default 0`
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
@@ -65,7 +65,7 @@ export class Migration20231101232834 extends Migration {
|
||||
async down(): Promise<void> {
|
||||
this.addSql('drop table if exists "price_list_rule_value" cascade;')
|
||||
|
||||
this.addSql(`ALTER TABLE price_list DROP COLUMN IF EXISTS number_rules`)
|
||||
this.addSql(`ALTER TABLE price_list DROP COLUMN IF EXISTS rules_count`)
|
||||
|
||||
this.addSql('alter table "price_list" drop column if exists "title";')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user