feat(pricing) Add Price Set Rule Type (#4977)
* initial * initial service * update pricing module service * add integration test for rule-type * update pricing-module integration tests * update pricing service interface * feat(pricing): PriceSets as entry point to pricing module * chore: add price set money amount * chore: add price set money amount * chore: change name of test * chore: added changeset * chore: use filterable props from money amount in price sets * chore: update migrations * test update integration test * fix weird behavior * Update packages/pricing/integration-tests/__fixtures__/rule-type/index.ts Co-authored-by: Riqwan Thamir <rmthamir@gmail.com> * Apply suggestions from code review Co-authored-by: Riqwan Thamir <rmthamir@gmail.com> * move rule-type to common * chore: reset migration * chore: remove incorrect conflicts * chore: address review * chore: remove ghost price list * Apply suggestions from code review Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> * update id prefix * use persist not persistAndflush * rename key_value to rule_attribute * more renaming --------- Co-authored-by: Riqwan Thamir <rmthamir@gmail.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
@@ -185,13 +185,22 @@
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"price_set_id": {
|
||||
"name": "price_set_id",
|
||||
"type": "text",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": true,
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"money_amount_id": {
|
||||
@@ -200,15 +209,6 @@
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": true,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
}
|
||||
@@ -217,13 +217,29 @@
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"keyName": "price_set_money_amount_pkey",
|
||||
"columnNames": [
|
||||
"id",
|
||||
"price_set_id",
|
||||
"price_set_id"
|
||||
],
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_set_money_amount_price_set_id",
|
||||
"primary": false,
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"columnNames": [
|
||||
"money_amount_id"
|
||||
],
|
||||
"composite": true,
|
||||
"composite": false,
|
||||
"keyName": "IDX_price_set_money_amount_money_amount_id",
|
||||
"primary": false,
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"keyName": "price_set_money_amount_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
}
|
||||
@@ -240,6 +256,7 @@
|
||||
"id"
|
||||
],
|
||||
"referencedTableName": "public.price_set",
|
||||
"deleteRule": "cascade",
|
||||
"updateRule": "cascade"
|
||||
},
|
||||
"price_set_money_amount_money_amount_id_foreign": {
|
||||
@@ -255,6 +272,71 @@
|
||||
"updateRule": "cascade"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"rule_attribute": {
|
||||
"name": "rule_attribute",
|
||||
"type": "text",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"default_priority": {
|
||||
"name": "default_priority",
|
||||
"type": "integer",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"default": "0",
|
||||
"mappedType": "integer"
|
||||
}
|
||||
},
|
||||
"name": "rule_type",
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"columnNames": [
|
||||
"rule_attribute"
|
||||
],
|
||||
"composite": false,
|
||||
"keyName": "IDX_rule_type_rule_attribute",
|
||||
"primary": false,
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"keyName": "rule_type_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
}
|
||||
],
|
||||
"checks": [],
|
||||
"foreignKeys": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+20
-4
@@ -1,6 +1,6 @@
|
||||
import { Migration } from "@mikro-orm/migrations"
|
||||
|
||||
export class Migration20230907144224 extends Migration {
|
||||
export class Migration20230913123118 extends Migration {
|
||||
async up(): Promise<void> {
|
||||
this.addSql(
|
||||
'create table "currency" ("code" text not null, "symbol" text not null, "symbol_native" text not null, "name" text not null, constraint "currency_pkey" primary key ("code"));'
|
||||
@@ -9,6 +9,7 @@ export class Migration20230907144224 extends Migration {
|
||||
this.addSql(
|
||||
'create table "money_amount" ("id" text not null, "currency_code" text null, "amount" numeric null, "min_quantity" numeric null, "max_quantity" numeric null, constraint "money_amount_pkey" primary key ("id"));'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'create index "IDX_money_amount_currency_code" on "money_amount" ("currency_code");'
|
||||
)
|
||||
@@ -18,7 +19,23 @@ export class Migration20230907144224 extends Migration {
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'create table "price_set_money_amount" ("id" text not null, "price_set_id" text null, "money_amount_id" text null, "title" text not null, constraint "price_set_money_amount_pkey" primary key ("id", "price_set_id", "money_amount_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, 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");'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'create index "IDX_price_set_money_amount_money_amount_id" on "price_set_money_amount" ("money_amount_id");'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'create table "rule_type" ("id" text not null, "name" text not null, "rule_attribute" text not null, "default_priority" integer not null default 0, constraint "rule_type_pkey" primary key ("id"));'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'create index "IDX_rule_type_rule_attribute" on "rule_type" ("rule_attribute");'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
@@ -26,9 +43,8 @@ export class Migration20230907144224 extends Migration {
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'alter table "price_set_money_amount" add constraint "price_set_money_amount_price_set_id_foreign" foreign key ("price_set_id") references "price_set" ("id") on update cascade;'
|
||||
'alter table "price_set_money_amount" add constraint "price_set_money_amount_price_set_id_foreign" foreign key ("price_set_id") references "price_set" ("id") on update cascade on delete cascade;'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'alter table "price_set_money_amount" add constraint "price_set_money_amount_money_amount_id_foreign" foreign key ("money_amount_id") references "money_amount" ("id") on update cascade;'
|
||||
)
|
||||
Reference in New Issue
Block a user