From 8a479e15708ecf41ce63462326ced1d62be9a9ac Mon Sep 17 00:00:00 2001 From: Michael Haufe Date: Thu, 5 Sep 2024 03:58:24 +0000 Subject: [PATCH] Fixed old migration of last_modified to have default value --- migrations/.snapshot-cathedral.json | 19 +++ migrations/Migration20240903022539.ts | 160 ++++++++++++------------ server/data/models/RequirementSchema.ts | 10 +- 3 files changed, 107 insertions(+), 82 deletions(-) diff --git a/migrations/.snapshot-cathedral.json b/migrations/.snapshot-cathedral.json index c29d5764..66382c9c 100644 --- a/migrations/.snapshot-cathedral.json +++ b/migrations/.snapshot-cathedral.json @@ -374,6 +374,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -478,6 +479,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -592,6 +594,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -696,6 +699,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -800,6 +804,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -919,6 +924,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -1023,6 +1029,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -1127,6 +1134,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -1231,6 +1239,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -1335,6 +1344,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -1461,6 +1471,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -1580,6 +1591,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -1706,6 +1718,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -1810,6 +1823,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -1928,6 +1942,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -2032,6 +2047,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -2204,6 +2220,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -2330,6 +2347,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { @@ -2571,6 +2589,7 @@ "primary": false, "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, "modified_by_id": { diff --git a/migrations/Migration20240903022539.ts b/migrations/Migration20240903022539.ts index ad676d1c..8d3de210 100644 --- a/migrations/Migration20240903022539.ts +++ b/migrations/Migration20240903022539.ts @@ -2,141 +2,141 @@ import { Migration } from '@mikro-orm/migrations'; export class Migration20240903022539 extends Migration { - override async up(): Promise { - this.addSql('alter table "product" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "product" add constraint "product_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + override async up(): Promise { + this.addSql('alter table "product" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "product" add constraint "product_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "person" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "person" add constraint "person_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "person" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "person" add constraint "person_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "outcome" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "outcome" add constraint "outcome_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "outcome" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "outcome" add constraint "outcome_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "obstacle" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "obstacle" add constraint "obstacle_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "obstacle" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "obstacle" add constraint "obstacle_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "non_functional_behavior" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "non_functional_behavior" add constraint "non_functional_behavior_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "non_functional_behavior" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "non_functional_behavior" add constraint "non_functional_behavior_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "limit" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "limit" add constraint "limit_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "limit" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "limit" add constraint "limit_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "justification" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "justification" add constraint "justification_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "justification" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "justification" add constraint "justification_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "invariant" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "invariant" add constraint "invariant_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "invariant" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "invariant" add constraint "invariant_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "hint" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "hint" add constraint "hint_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "hint" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "hint" add constraint "hint_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "glossary_term" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "glossary_term" add constraint "glossary_term_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "glossary_term" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "glossary_term" add constraint "glossary_term_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "functional_behavior" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "functional_behavior" add constraint "functional_behavior_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "functional_behavior" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "functional_behavior" add constraint "functional_behavior_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "environment_component" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "environment_component" add constraint "environment_component_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "environment_component" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "environment_component" add constraint "environment_component_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "effect" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "effect" add constraint "effect_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "effect" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "effect" add constraint "effect_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "constraint" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "constraint" add constraint "constraint_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "constraint" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "constraint" add constraint "constraint_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "assumption" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "assumption" add constraint "assumption_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "assumption" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "assumption" add constraint "assumption_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "stakeholder" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "stakeholder" add constraint "stakeholder_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "stakeholder" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "stakeholder" add constraint "stakeholder_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "system_component" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "system_component" add constraint "system_component_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "system_component" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "system_component" add constraint "system_component_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "use_case" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "use_case" add constraint "use_case_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + this.addSql('alter table "use_case" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "use_case" add constraint "use_case_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - this.addSql('alter table "user_story" add column "last_modified" timestamptz not null, add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); - this.addSql('alter table "user_story" add constraint "user_story_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); - } + this.addSql('alter table "user_story" add column "last_modified" timestamptz not null default now(), add column "modified_by_id" uuid not null default \'ac594919-50e3-438a-b9bc-efb8a8654243\';'); + this.addSql('alter table "user_story" add constraint "user_story_modified_by_id_foreign" foreign key ("modified_by_id") references "app_user" ("id") on update cascade;'); + } - override async down(): Promise { - this.addSql('alter table "product" drop constraint "product_modified_by_id_foreign";'); + override async down(): Promise { + this.addSql('alter table "product" drop constraint "product_modified_by_id_foreign";'); - this.addSql('alter table "person" drop constraint "person_modified_by_id_foreign";'); + this.addSql('alter table "person" drop constraint "person_modified_by_id_foreign";'); - this.addSql('alter table "outcome" drop constraint "outcome_modified_by_id_foreign";'); + this.addSql('alter table "outcome" drop constraint "outcome_modified_by_id_foreign";'); - this.addSql('alter table "obstacle" drop constraint "obstacle_modified_by_id_foreign";'); + this.addSql('alter table "obstacle" drop constraint "obstacle_modified_by_id_foreign";'); - this.addSql('alter table "non_functional_behavior" drop constraint "non_functional_behavior_modified_by_id_foreign";'); + this.addSql('alter table "non_functional_behavior" drop constraint "non_functional_behavior_modified_by_id_foreign";'); - this.addSql('alter table "limit" drop constraint "limit_modified_by_id_foreign";'); + this.addSql('alter table "limit" drop constraint "limit_modified_by_id_foreign";'); - this.addSql('alter table "justification" drop constraint "justification_modified_by_id_foreign";'); + this.addSql('alter table "justification" drop constraint "justification_modified_by_id_foreign";'); - this.addSql('alter table "invariant" drop constraint "invariant_modified_by_id_foreign";'); + this.addSql('alter table "invariant" drop constraint "invariant_modified_by_id_foreign";'); - this.addSql('alter table "hint" drop constraint "hint_modified_by_id_foreign";'); + this.addSql('alter table "hint" drop constraint "hint_modified_by_id_foreign";'); - this.addSql('alter table "glossary_term" drop constraint "glossary_term_modified_by_id_foreign";'); + this.addSql('alter table "glossary_term" drop constraint "glossary_term_modified_by_id_foreign";'); - this.addSql('alter table "functional_behavior" drop constraint "functional_behavior_modified_by_id_foreign";'); + this.addSql('alter table "functional_behavior" drop constraint "functional_behavior_modified_by_id_foreign";'); - this.addSql('alter table "environment_component" drop constraint "environment_component_modified_by_id_foreign";'); + this.addSql('alter table "environment_component" drop constraint "environment_component_modified_by_id_foreign";'); - this.addSql('alter table "effect" drop constraint "effect_modified_by_id_foreign";'); + this.addSql('alter table "effect" drop constraint "effect_modified_by_id_foreign";'); - this.addSql('alter table "constraint" drop constraint "constraint_modified_by_id_foreign";'); + this.addSql('alter table "constraint" drop constraint "constraint_modified_by_id_foreign";'); - this.addSql('alter table "assumption" drop constraint "assumption_modified_by_id_foreign";'); + this.addSql('alter table "assumption" drop constraint "assumption_modified_by_id_foreign";'); - this.addSql('alter table "stakeholder" drop constraint "stakeholder_modified_by_id_foreign";'); + this.addSql('alter table "stakeholder" drop constraint "stakeholder_modified_by_id_foreign";'); - this.addSql('alter table "system_component" drop constraint "system_component_modified_by_id_foreign";'); + this.addSql('alter table "system_component" drop constraint "system_component_modified_by_id_foreign";'); - this.addSql('alter table "use_case" drop constraint "use_case_modified_by_id_foreign";'); + this.addSql('alter table "use_case" drop constraint "use_case_modified_by_id_foreign";'); - this.addSql('alter table "user_story" drop constraint "user_story_modified_by_id_foreign";'); + this.addSql('alter table "user_story" drop constraint "user_story_modified_by_id_foreign";'); - this.addSql('alter table "product" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "product" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "person" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "person" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "outcome" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "outcome" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "obstacle" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "obstacle" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "non_functional_behavior" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "non_functional_behavior" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "limit" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "limit" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "justification" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "justification" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "invariant" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "invariant" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "hint" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "hint" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "glossary_term" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "glossary_term" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "functional_behavior" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "functional_behavior" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "environment_component" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "environment_component" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "effect" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "effect" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "constraint" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "constraint" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "assumption" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "assumption" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "stakeholder" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "stakeholder" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "system_component" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "system_component" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "use_case" drop column "last_modified", drop column "modified_by_id";'); + this.addSql('alter table "use_case" drop column "last_modified", drop column "modified_by_id";'); - this.addSql('alter table "user_story" drop column "last_modified", drop column "modified_by_id";'); - } + this.addSql('alter table "user_story" drop column "last_modified", drop column "modified_by_id";'); + } } diff --git a/server/data/models/RequirementSchema.ts b/server/data/models/RequirementSchema.ts index 32c7fcdb..96236745 100644 --- a/server/data/models/RequirementSchema.ts +++ b/server/data/models/RequirementSchema.ts @@ -1,4 +1,4 @@ -import { Cascade, EntitySchema } from "@mikro-orm/core"; +import { EntitySchema } from "@mikro-orm/core"; import { Requirement } from "../../domain/requirements/index.js"; export default new EntitySchema({ @@ -9,7 +9,13 @@ export default new EntitySchema({ name: { type: 'string', nullable: false }, statement: { type: 'string', nullable: false }, solution: { kind: 'm:1', entity: 'Solution' }, - lastModified: { type: 'datetime', nullable: false, onCreate: () => new Date(), onUpdate: () => new Date() }, + lastModified: { + type: 'datetime', + nullable: false, + onCreate: () => new Date(), + onUpdate: () => new Date(), + defaultRaw: 'now()' + }, modifiedBy: { kind: 'm:1', entity: 'AppUser', nullable: false, // System Admin is the default user for the initial migration