feat(pricing): add price rule entity (#5050)
**What** - add price-rule entity to pricing module blocked by #4977 Fixes CORE-1497 Co-authored-by: Riqwan Thamir <5105988+riqwan@users.noreply.github.com> Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
co-authored by
Riqwan Thamir
Adrien de Peretti
parent
b3f1135fba
commit
bc42b201ea
@@ -337,6 +337,145 @@
|
||||
],
|
||||
"checks": [],
|
||||
"foreignKeys": {}
|
||||
},
|
||||
{
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"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": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"rule_type_id": {
|
||||
"name": "rule_type_id",
|
||||
"type": "text",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"is_dynamic": {
|
||||
"name": "is_dynamic",
|
||||
"type": "boolean",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"default": "false",
|
||||
"mappedType": "boolean"
|
||||
},
|
||||
"value": {
|
||||
"name": "value",
|
||||
"type": "text",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"priority": {
|
||||
"name": "priority",
|
||||
"type": "integer",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"default": "0",
|
||||
"mappedType": "integer"
|
||||
},
|
||||
"price_set_money_amount_id": {
|
||||
"name": "price_set_money_amount_id",
|
||||
"type": "text",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"price_list_id": {
|
||||
"name": "price_list_id",
|
||||
"type": "text",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
}
|
||||
},
|
||||
"name": "price_rule",
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"columnNames": [
|
||||
"rule_type_id"
|
||||
],
|
||||
"composite": false,
|
||||
"keyName": "price_rule_rule_type_id_unique",
|
||||
"primary": false,
|
||||
"unique": true
|
||||
},
|
||||
{
|
||||
"keyName": "price_rule_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"composite": false,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
}
|
||||
],
|
||||
"checks": [],
|
||||
"foreignKeys": {
|
||||
"price_rule_price_set_id_foreign": {
|
||||
"constraintName": "price_rule_price_set_id_foreign",
|
||||
"columnNames": [
|
||||
"price_set_id"
|
||||
],
|
||||
"localTableName": "public.price_rule",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedTableName": "public.price_set",
|
||||
"updateRule": "cascade"
|
||||
},
|
||||
"price_rule_rule_type_id_foreign": {
|
||||
"constraintName": "price_rule_rule_type_id_foreign",
|
||||
"columnNames": [
|
||||
"rule_type_id"
|
||||
],
|
||||
"localTableName": "public.price_rule",
|
||||
"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"
|
||||
],
|
||||
"localTableName": "public.price_rule",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedTableName": "public.price_set_money_amount",
|
||||
"updateRule": "cascade"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Migration } from '@mikro-orm/migrations';
|
||||
|
||||
export class Migration20230913055746 extends Migration {
|
||||
|
||||
async up(): Promise<void> {
|
||||
this.addSql('create table "price_rule" ("id" text not null, "price_set_id" text not null, "rule_type_id" text not null, "is_dynamic" boolean not null default false, "value" text not null, "priority" integer not null default 0, "price_set_money_amount_id" text not null, "price_list_id" text not null, constraint "price_rule_pkey" primary key ("id"));');
|
||||
|
||||
this.addSql('alter table "price_rule" add constraint "price_rule_price_set_id_foreign" foreign key ("price_set_id") references "price_set" ("id") on update cascade;');
|
||||
this.addSql('alter table "price_rule" add constraint "price_rule_rule_type_id_foreign" foreign key ("rule_type_id") references "rule_type" ("id") on update cascade;');
|
||||
this.addSql('alter table "price_rule" add constraint "price_rule_price_set_money_amount_id_foreign" foreign key ("price_set_money_amount_id") references "price_set_money_amount" ("id") on update cascade;');
|
||||
}
|
||||
|
||||
async down(): Promise<void> {
|
||||
this.addSql('alter table "price_rule" drop constraint "price_rule_price_set_id_foreign";');
|
||||
|
||||
this.addSql('alter table "price_rule" drop constraint "price_rule_price_set_money_amount_id_foreign";');
|
||||
|
||||
this.addSql('alter table "price_rule" drop constraint "price_rule_rule_type_id_foreign";');
|
||||
|
||||
this.addSql('drop table if exists "price_rule" cascade;');
|
||||
}g
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user