@open-mercato/core 0.4.2-canary-15e78de280 → 0.4.2-canary-f075c3eb92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/api_keys/setup.js +11 -0
- package/dist/modules/api_keys/setup.js.map +7 -0
- package/dist/modules/attachments/components/AttachmentLibrary.js +1 -1
- package/dist/modules/attachments/components/AttachmentLibrary.js.map +2 -2
- package/dist/modules/attachments/lib/assignmentDetails.js +31 -17
- package/dist/modules/attachments/lib/assignmentDetails.js.map +2 -2
- package/dist/modules/attachments/lib/partitions.js +3 -3
- package/dist/modules/attachments/lib/partitions.js.map +2 -2
- package/dist/modules/attachments/setup.js +11 -0
- package/dist/modules/attachments/setup.js.map +7 -0
- package/dist/modules/audit_logs/setup.js +12 -0
- package/dist/modules/audit_logs/setup.js.map +7 -0
- package/dist/modules/auth/lib/setup-app.js +29 -159
- package/dist/modules/auth/lib/setup-app.js.map +2 -2
- package/dist/modules/auth/setup.js +11 -0
- package/dist/modules/auth/setup.js.map +7 -0
- package/dist/modules/business_rules/setup.js +11 -0
- package/dist/modules/business_rules/setup.js.map +7 -0
- package/dist/modules/catalog/setup.js +22 -0
- package/dist/modules/catalog/setup.js.map +7 -0
- package/dist/modules/configs/lib/upgrade-actions.js +65 -15
- package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
- package/dist/modules/configs/setup.js +16 -0
- package/dist/modules/configs/setup.js.map +7 -0
- package/dist/modules/currencies/setup.js +16 -0
- package/dist/modules/currencies/setup.js.map +7 -0
- package/dist/modules/customers/setup.js +36 -0
- package/dist/modules/customers/setup.js.map +7 -0
- package/dist/modules/dashboards/setup.js +12 -0
- package/dist/modules/dashboards/setup.js.map +7 -0
- package/dist/modules/dictionaries/setup.js +12 -0
- package/dist/modules/dictionaries/setup.js.map +7 -0
- package/dist/modules/directory/setup.js +12 -0
- package/dist/modules/directory/setup.js.map +7 -0
- package/dist/modules/entities/setup.js +11 -0
- package/dist/modules/entities/setup.js.map +7 -0
- package/dist/modules/feature_toggles/setup.js +11 -0
- package/dist/modules/feature_toggles/setup.js.map +7 -0
- package/dist/modules/perspectives/setup.js +12 -0
- package/dist/modules/perspectives/setup.js.map +7 -0
- package/dist/modules/planner/setup.js +21 -0
- package/dist/modules/planner/setup.js.map +7 -0
- package/dist/modules/query_index/setup.js +11 -0
- package/dist/modules/query_index/setup.js.map +7 -0
- package/dist/modules/resources/setup.js +21 -0
- package/dist/modules/resources/setup.js.map +7 -0
- package/dist/modules/sales/setup.js +99 -0
- package/dist/modules/sales/setup.js.map +7 -0
- package/dist/modules/staff/setup.js +27 -0
- package/dist/modules/staff/setup.js.map +7 -0
- package/dist/modules/workflows/lib/seeds.js +3 -15
- package/dist/modules/workflows/lib/seeds.js.map +2 -2
- package/dist/modules/workflows/migrations/Migration20251207131955.js +76 -72
- package/dist/modules/workflows/migrations/Migration20251207131955.js.map +2 -2
- package/dist/modules/workflows/setup.js +16 -0
- package/dist/modules/workflows/setup.js.map +7 -0
- package/package.json +2 -2
- package/src/__tests__/module-decoupling.test.ts +356 -0
- package/src/modules/api_keys/setup.ts +9 -0
- package/src/modules/attachments/components/AttachmentLibrary.tsx +2 -2
- package/src/modules/attachments/lib/assignmentDetails.ts +32 -16
- package/src/modules/attachments/lib/partitions.ts +3 -3
- package/src/modules/attachments/setup.ts +9 -0
- package/src/modules/audit_logs/setup.ts +10 -0
- package/src/modules/auth/__tests__/cli-setup-acl.test.ts +30 -0
- package/src/modules/auth/lib/setup-app.ts +40 -177
- package/src/modules/auth/setup.ts +9 -0
- package/src/modules/business_rules/setup.ts +9 -0
- package/src/modules/catalog/setup.ts +22 -0
- package/src/modules/configs/lib/upgrade-actions.ts +78 -17
- package/src/modules/configs/setup.ts +14 -0
- package/src/modules/currencies/setup.ts +15 -0
- package/src/modules/customers/setup.ts +36 -0
- package/src/modules/dashboards/setup.ts +10 -0
- package/src/modules/dictionaries/setup.ts +10 -0
- package/src/modules/directory/setup.ts +10 -0
- package/src/modules/entities/setup.ts +9 -0
- package/src/modules/feature_toggles/setup.ts +9 -0
- package/src/modules/perspectives/setup.ts +10 -0
- package/src/modules/planner/setup.ts +21 -0
- package/src/modules/query_index/setup.ts +9 -0
- package/src/modules/resources/setup.ts +21 -0
- package/src/modules/sales/setup.ts +108 -0
- package/src/modules/staff/setup.ts +27 -0
- package/src/modules/workflows/lib/seeds.ts +4 -16
- package/src/modules/workflows/migrations/Migration20251207131955.ts +77 -143
- package/src/modules/workflows/setup.ts +15 -0
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
3
4
|
import { WorkflowDefinition } from "../data/entities.js";
|
|
4
5
|
import { BusinessRule } from "@open-mercato/core/modules/business_rules/data/entities";
|
|
5
|
-
|
|
6
|
-
import guardRulesExample from "../examples/guard-rules-example.json";
|
|
7
|
-
import salesPipelineDefinition from "../examples/sales-pipeline-definition.json";
|
|
8
|
-
import simpleApprovalDefinition from "../examples/simple-approval-definition.json";
|
|
9
|
-
const embeddedSeeds = {
|
|
10
|
-
"checkout-demo-definition.json": checkoutDemoDefinition,
|
|
11
|
-
"guard-rules-example.json": guardRulesExample,
|
|
12
|
-
"sales-pipeline-definition.json": salesPipelineDefinition,
|
|
13
|
-
"simple-approval-definition.json": simpleApprovalDefinition
|
|
14
|
-
};
|
|
6
|
+
const __esmDirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
7
|
function readExampleJson(fileName) {
|
|
16
|
-
const embedded = embeddedSeeds[fileName];
|
|
17
|
-
if (embedded) {
|
|
18
|
-
return embedded;
|
|
19
|
-
}
|
|
20
8
|
const candidates = [
|
|
21
|
-
path.join(
|
|
9
|
+
path.join(__esmDirname, "..", "examples", fileName),
|
|
22
10
|
path.join(process.cwd(), "packages", "core", "src", "modules", "workflows", "examples", fileName),
|
|
23
11
|
path.join(process.cwd(), "src", "modules", "workflows", "examples", fileName)
|
|
24
12
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/workflows/lib/seeds.ts"],
|
|
4
|
-
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport * as fs from 'fs'\nimport * as path from 'path'\nimport { WorkflowDefinition, type WorkflowDefinitionData } from '../data/entities'\nimport { BusinessRule, type RuleType } from '@open-mercato/core/modules/business_rules/data/entities'\
|
|
5
|
-
"mappings": "AACA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,0BAAuD;AAChE,SAAS,oBAAmC;
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport * as fs from 'fs'\nimport * as path from 'path'\nimport { fileURLToPath } from 'node:url'\nimport { WorkflowDefinition, type WorkflowDefinitionData } from '../data/entities'\nimport { BusinessRule, type RuleType } from '@open-mercato/core/modules/business_rules/data/entities'\n\nconst __esmDirname = path.dirname(fileURLToPath(import.meta.url))\n\nexport type WorkflowSeedScope = { tenantId: string; organizationId: string }\n\ntype WorkflowSeedDefinition = {\n workflowId: string\n workflowName: string\n description?: string | null\n version?: number\n definition: WorkflowDefinitionData\n metadata?: Record<string, unknown> | null\n enabled?: boolean\n effectiveFrom?: string | null\n effectiveTo?: string | null\n createdBy?: string | null\n updatedBy?: string | null\n}\n\ntype GuardRuleSeed = {\n ruleId: string\n ruleName: string\n ruleType: RuleType\n entityType: string\n conditionExpression: unknown\n eventType?: string | null\n ruleCategory?: string | null\n description?: string | null\n successActions?: unknown\n failureActions?: unknown\n enabled?: boolean\n priority?: number\n version?: number\n effectiveFrom?: string | null\n effectiveTo?: string | null\n createdBy?: string | null\n updatedBy?: string | null\n tagsJson?: string[]\n labelsJson?: Record<string, string>\n}\n\nfunction readExampleJson<T>(fileName: string): T {\n const candidates = [\n path.join(__esmDirname, '..', 'examples', fileName),\n path.join(process.cwd(), 'packages', 'core', 'src', 'modules', 'workflows', 'examples', fileName),\n path.join(process.cwd(), 'src', 'modules', 'workflows', 'examples', fileName),\n ]\n const filePath = candidates.find((candidate) => fs.existsSync(candidate))\n if (!filePath) {\n throw new Error(`Missing workflow seed file: ${fileName}`)\n }\n return JSON.parse(fs.readFileSync(filePath, 'utf8')) as T\n}\n\nfunction requireString(value: unknown, label: string): string {\n if (typeof value === 'string' && value.trim().length > 0) return value\n throw new Error(`Invalid ${label} in workflow seed data.`)\n}\n\nasync function seedWorkflowDefinition(\n em: EntityManager,\n scope: WorkflowSeedScope,\n fileName: string,\n): Promise<boolean> {\n const seed = readExampleJson<WorkflowSeedDefinition>(fileName)\n const workflowId = requireString(seed.workflowId, 'workflowId')\n\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n\n if (existing) {\n // Check if the definition needs to be updated (e.g., missing preConditions on START step)\n const seedStartStep = seed.definition.steps.find((s: any) => s.stepType === 'START')\n const existingStartStep = existing.definition.steps.find((s: any) => s.stepType === 'START')\n\n const seedHasPreConditions = seedStartStep?.preConditions && seedStartStep.preConditions.length > 0\n const existingHasPreConditions = existingStartStep?.preConditions && existingStartStep.preConditions.length > 0\n\n // Update if seed has preConditions but existing doesn't\n if (seedHasPreConditions && !existingHasPreConditions) {\n console.log(`[seed] Updating workflow ${workflowId} with preConditions`)\n existing.definition = seed.definition\n await em.flush()\n return true\n }\n\n return false\n }\n\n const workflow = em.create(WorkflowDefinition, {\n ...seed,\n workflowId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n em.persist(workflow)\n await em.flush()\n return true\n}\n\nasync function seedGuardRules(\n em: EntityManager,\n scope: WorkflowSeedScope,\n fileName: string,\n): Promise<{ seeded: number; skipped: number; updated: number }> {\n const seeds = readExampleJson<GuardRuleSeed[]>(fileName)\n if (!Array.isArray(seeds)) {\n throw new Error('Invalid guard rules seed data.')\n }\n\n let seeded = 0\n let skipped = 0\n let updated = 0\n for (const rule of seeds) {\n const ruleId = requireString(rule.ruleId, 'ruleId')\n const existing = await em.findOne(BusinessRule, {\n ruleId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n if (existing) {\n // Check if entityType or eventType needs updating\n const needsUpdate = existing.entityType !== rule.entityType || existing.eventType !== rule.eventType\n if (needsUpdate) {\n console.log(`[seed] Updating business rule ${ruleId}: entityType=${rule.entityType}, eventType=${rule.eventType}`)\n existing.entityType = rule.entityType\n existing.eventType = rule.eventType ?? null\n updated += 1\n } else {\n skipped += 1\n }\n continue\n }\n const entry = em.create(BusinessRule, {\n ...rule,\n ruleId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n em.persist(entry)\n seeded += 1\n }\n if (seeded > 0 || updated > 0) {\n await em.flush()\n }\n return { seeded, skipped, updated }\n}\n\nexport async function seedExampleWorkflows(em: EntityManager, scope: WorkflowSeedScope): Promise<void> {\n await seedWorkflowDefinition(em, scope, 'checkout-demo-definition.json')\n await seedGuardRules(em, scope, 'guard-rules-example.json')\n await seedWorkflowDefinition(em, scope, 'sales-pipeline-definition.json')\n await seedWorkflowDefinition(em, scope, 'simple-approval-definition.json')\n}\n"],
|
|
5
|
+
"mappings": "AACA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,qBAAqB;AAC9B,SAAS,0BAAuD;AAChE,SAAS,oBAAmC;AAE5C,MAAM,eAAe,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAwChE,SAAS,gBAAmB,UAAqB;AAC/C,QAAM,aAAa;AAAA,IACjB,KAAK,KAAK,cAAc,MAAM,YAAY,QAAQ;AAAA,IAClD,KAAK,KAAK,QAAQ,IAAI,GAAG,YAAY,QAAQ,OAAO,WAAW,aAAa,YAAY,QAAQ;AAAA,IAChG,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO,WAAW,aAAa,YAAY,QAAQ;AAAA,EAC9E;AACA,QAAM,WAAW,WAAW,KAAK,CAAC,cAAc,GAAG,WAA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
|
1
1
|
import { Migration } from "@mikro-orm/migrations";
|
|
2
2
|
class Migration20251207131955 extends Migration {
|
|
3
|
+
/** Drop a foreign key constraint only when the owning table exists (safe for disabled modules). */
|
|
4
|
+
dropConstraintIfTableExists(table, constraint) {
|
|
5
|
+
this.addSql(`DO $$ BEGIN IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = '${table}') THEN ALTER TABLE "${table}" DROP CONSTRAINT IF EXISTS "${constraint}"; END IF; END $$;`);
|
|
6
|
+
}
|
|
3
7
|
async up() {
|
|
4
|
-
this.
|
|
5
|
-
this.
|
|
6
|
-
this.
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
60
|
-
this.
|
|
61
|
-
this.
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
66
|
-
this.
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
8
|
+
this.dropConstraintIfTableExists("rule_execution_logs", "rule_execution_logs_rule_id_foreign");
|
|
9
|
+
this.dropConstraintIfTableExists("rule_set_members", "rule_set_members_rule_id_foreign");
|
|
10
|
+
this.dropConstraintIfTableExists("catalog_product_variant_prices", "catalog_product_variant_prices_price_kind_id_foreign");
|
|
11
|
+
this.dropConstraintIfTableExists("catalog_product_category_assignments", "catalog_product_category_assignments_category_id_foreign");
|
|
12
|
+
this.dropConstraintIfTableExists("catalog_product_variant_prices", "catalog_product_variant_prices_offer_id_foreign");
|
|
13
|
+
this.dropConstraintIfTableExists("catalog_products", "catalog_products_option_schema_id_foreign");
|
|
14
|
+
this.dropConstraintIfTableExists("catalog_product_tag_assignments", "catalog_product_tag_assignments_tag_id_foreign");
|
|
15
|
+
this.dropConstraintIfTableExists("catalog_product_variant_option_values", "catalog_product_variant_option_values_variant_id_foreign");
|
|
16
|
+
this.dropConstraintIfTableExists("catalog_product_variant_prices", "catalog_product_variant_prices_variant_id_foreign");
|
|
17
|
+
this.dropConstraintIfTableExists("catalog_product_variant_relations", "catalog_product_variant_relations_child_variant_id_foreign");
|
|
18
|
+
this.dropConstraintIfTableExists("catalog_product_variant_relations", "catalog_product_variant_relations_parent_variant_id_foreign");
|
|
19
|
+
this.dropConstraintIfTableExists("catalog_product_category_assignments", "catalog_product_category_assignments_product_id_foreign");
|
|
20
|
+
this.dropConstraintIfTableExists("catalog_product_offers", "catalog_product_offers_product_id_foreign");
|
|
21
|
+
this.dropConstraintIfTableExists("catalog_product_options", "catalog_product_options_product_id_foreign");
|
|
22
|
+
this.dropConstraintIfTableExists("catalog_product_relations", "catalog_product_relations_child_product_id_foreign");
|
|
23
|
+
this.dropConstraintIfTableExists("catalog_product_relations", "catalog_product_relations_parent_product_id_foreign");
|
|
24
|
+
this.dropConstraintIfTableExists("catalog_product_tag_assignments", "catalog_product_tag_assignments_product_id_foreign");
|
|
25
|
+
this.dropConstraintIfTableExists("catalog_product_variant_prices", "catalog_product_variant_prices_product_id_foreign");
|
|
26
|
+
this.dropConstraintIfTableExists("catalog_product_variants", "catalog_product_variants_product_id_foreign");
|
|
27
|
+
this.dropConstraintIfTableExists("customer_activities", "customer_activities_deal_id_foreign");
|
|
28
|
+
this.dropConstraintIfTableExists("customer_comments", "customer_comments_deal_id_foreign");
|
|
29
|
+
this.dropConstraintIfTableExists("customer_deal_companies", "customer_deal_companies_deal_id_foreign");
|
|
30
|
+
this.dropConstraintIfTableExists("customer_deal_people", "customer_deal_people_deal_id_foreign");
|
|
31
|
+
this.dropConstraintIfTableExists("customer_activities", "customer_activities_entity_id_foreign");
|
|
32
|
+
this.dropConstraintIfTableExists("customer_addresses", "customer_addresses_entity_id_foreign");
|
|
33
|
+
this.dropConstraintIfTableExists("customer_comments", "customer_comments_entity_id_foreign");
|
|
34
|
+
this.dropConstraintIfTableExists("customer_companies", "customer_companies_entity_id_foreign");
|
|
35
|
+
this.dropConstraintIfTableExists("customer_deal_companies", "customer_deal_companies_company_entity_id_foreign");
|
|
36
|
+
this.dropConstraintIfTableExists("customer_deal_people", "customer_deal_people_person_entity_id_foreign");
|
|
37
|
+
this.dropConstraintIfTableExists("customer_people", "customer_people_company_entity_id_foreign");
|
|
38
|
+
this.dropConstraintIfTableExists("customer_people", "customer_people_entity_id_foreign");
|
|
39
|
+
this.dropConstraintIfTableExists("customer_tag_assignments", "customer_tag_assignments_entity_id_foreign");
|
|
40
|
+
this.dropConstraintIfTableExists("customer_todo_links", "customer_todo_links_entity_id_foreign");
|
|
41
|
+
this.dropConstraintIfTableExists("customer_tag_assignments", "customer_tag_assignments_tag_id_foreign");
|
|
42
|
+
this.dropConstraintIfTableExists("dictionary_entries", "dictionary_entries_dictionary_id_foreign");
|
|
43
|
+
this.dropConstraintIfTableExists("role_acls", "role_acls_role_id_foreign");
|
|
44
|
+
this.dropConstraintIfTableExists("role_sidebar_preferences", "role_sidebar_preferences_role_id_foreign");
|
|
45
|
+
this.dropConstraintIfTableExists("user_roles", "user_roles_role_id_foreign");
|
|
46
|
+
this.dropConstraintIfTableExists("rule_set_members", "rule_set_members_rule_set_id_foreign");
|
|
47
|
+
this.dropConstraintIfTableExists("sales_orders", "sales_orders_channel_ref_id_foreign");
|
|
48
|
+
this.dropConstraintIfTableExists("sales_credit_memo_lines", "sales_credit_memo_lines_credit_memo_id_foreign");
|
|
49
|
+
this.dropConstraintIfTableExists("sales_orders", "sales_orders_delivery_window_ref_id_foreign");
|
|
50
|
+
this.dropConstraintIfTableExists("sales_credit_memos", "sales_credit_memos_invoice_id_foreign");
|
|
51
|
+
this.dropConstraintIfTableExists("sales_invoice_lines", "sales_invoice_lines_invoice_id_foreign");
|
|
52
|
+
this.dropConstraintIfTableExists("sales_payment_allocations", "sales_payment_allocations_invoice_id_foreign");
|
|
53
|
+
this.dropConstraintIfTableExists("sales_credit_memo_lines", "sales_credit_memo_lines_order_line_id_foreign");
|
|
54
|
+
this.dropConstraintIfTableExists("sales_invoice_lines", "sales_invoice_lines_order_line_id_foreign");
|
|
55
|
+
this.dropConstraintIfTableExists("sales_order_adjustments", "sales_order_adjustments_order_line_id_foreign");
|
|
56
|
+
this.dropConstraintIfTableExists("sales_shipment_items", "sales_shipment_items_order_line_id_foreign");
|
|
57
|
+
this.dropConstraintIfTableExists("sales_credit_memos", "sales_credit_memos_order_id_foreign");
|
|
58
|
+
this.dropConstraintIfTableExists("sales_invoices", "sales_invoices_order_id_foreign");
|
|
59
|
+
this.dropConstraintIfTableExists("sales_notes", "sales_notes_order_id_foreign");
|
|
60
|
+
this.dropConstraintIfTableExists("sales_order_adjustments", "sales_order_adjustments_order_id_foreign");
|
|
61
|
+
this.dropConstraintIfTableExists("sales_order_lines", "sales_order_lines_order_id_foreign");
|
|
62
|
+
this.dropConstraintIfTableExists("sales_payment_allocations", "sales_payment_allocations_order_id_foreign");
|
|
63
|
+
this.dropConstraintIfTableExists("sales_payments", "sales_payments_order_id_foreign");
|
|
64
|
+
this.dropConstraintIfTableExists("sales_shipments", "sales_shipments_order_id_foreign");
|
|
65
|
+
this.dropConstraintIfTableExists("sales_orders", "sales_orders_payment_method_ref_id_foreign");
|
|
66
|
+
this.dropConstraintIfTableExists("sales_payments", "sales_payments_payment_method_id_foreign");
|
|
67
|
+
this.dropConstraintIfTableExists("sales_payment_allocations", "sales_payment_allocations_payment_id_foreign");
|
|
68
|
+
this.dropConstraintIfTableExists("sales_quote_adjustments", "sales_quote_adjustments_quote_line_id_foreign");
|
|
69
|
+
this.dropConstraintIfTableExists("sales_notes", "sales_notes_quote_id_foreign");
|
|
70
|
+
this.dropConstraintIfTableExists("sales_quote_adjustments", "sales_quote_adjustments_quote_id_foreign");
|
|
71
|
+
this.dropConstraintIfTableExists("sales_quote_lines", "sales_quote_lines_quote_id_foreign");
|
|
72
|
+
this.dropConstraintIfTableExists("sales_shipment_items", "sales_shipment_items_shipment_id_foreign");
|
|
73
|
+
this.dropConstraintIfTableExists("sales_orders", "sales_orders_shipping_method_ref_id_foreign");
|
|
74
|
+
this.dropConstraintIfTableExists("organizations", "organizations_tenant_id_foreign");
|
|
75
|
+
this.dropConstraintIfTableExists("password_resets", "password_resets_user_id_foreign");
|
|
76
|
+
this.dropConstraintIfTableExists("sessions", "sessions_user_id_foreign");
|
|
77
|
+
this.dropConstraintIfTableExists("user_acls", "user_acls_user_id_foreign");
|
|
78
|
+
this.dropConstraintIfTableExists("user_roles", "user_roles_user_id_foreign");
|
|
79
|
+
this.dropConstraintIfTableExists("user_sidebar_preferences", "user_sidebar_preferences_user_id_foreign");
|
|
76
80
|
this.addSql(`create table "step_instances" ("id" uuid not null default gen_random_uuid(), "workflow_instance_id" uuid not null, "step_id" varchar(100) not null, "step_name" varchar(255) not null, "step_type" varchar(50) not null, "status" varchar(20) not null, "input_data" jsonb null, "output_data" jsonb null, "error_data" jsonb null, "entered_at" timestamptz null, "exited_at" timestamptz null, "execution_time_ms" int null, "retry_count" int not null default 0, "tenant_id" uuid not null, "organization_id" uuid not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "step_instances_pkey" primary key ("id"));`);
|
|
77
81
|
this.addSql(`create index "step_instances_tenant_org_idx" on "step_instances" ("tenant_id", "organization_id");`);
|
|
78
82
|
this.addSql(`create index "step_instances_step_id_idx" on "step_instances" ("step_id", "status");`);
|