Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defined nullable fields #364

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions components/XDataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ const onEditDialogCancel = () => {
<div class="field grid"
v-for="key of Object.keys(props.createModel).filter(k => props.createModel[k as keyof RowType] !== 'hidden')"
:key="key" :field="key">
<label :for="key" class="required col-4">{{ camelCaseToTitle(key) }}</label>
<label :for="key" class="col-4">{{ camelCaseToTitle(key) }}</label>

<InputText v-if="props.createModel[key as keyof RowType] === 'text'" :name="key"
v-model.trim="createDialogItem[key]" required class="col-8" />
v-model.trim="createDialogItem[key]" class="col-8" />
<InputNumber v-else-if="
typeof props.createModel[key as keyof RowType] === 'object' &&
(props.createModel[key as keyof RowType] as any).type === 'number'
Expand Down Expand Up @@ -202,7 +202,7 @@ const onEditDialogCancel = () => {
</select>

<Textarea v-else-if="props.createModel[key as keyof RowType] === 'textarea'" :name="key"
v-model.trim="createDialogItem[key]" required class="col-8" />
v-model.trim="createDialogItem[key]" class="col-8" />
<span v-else>{{ createDialogItem[key] }}</span>
</div>
</form>
Expand All @@ -216,11 +216,11 @@ const onEditDialogCancel = () => {
<template #header>Edit Item</template>
<form id="editDialogForm" autocomplete="off" @submit.prevent="onEditDialogSave" @reset="onEditDialogCancel">
<div class="field grid" v-for="key of Object.keys(props.editModel)" :key="key" :field="key">
<label v-if="props.editModel[key as keyof RowType] !== 'hidden'" :for="key" class="required col-4">{{
<label v-if="props.editModel[key as keyof RowType] !== 'hidden'" :for="key" class="col-4">{{
camelCaseToTitle(key) }}</label>

<InputText v-if="props.editModel[key as keyof RowType] === 'text'" :name="key"
v-model.trim="editDialogItem[key]" required class="col-8" />
v-model.trim="editDialogItem[key]" class="col-8" />
<input v-else-if="props.editModel[key as keyof RowType] === 'hidden'" type="hidden" :name="key"
v-model.trim="editDialogItem[key]" />
<InputNumber v-else-if="
Expand Down Expand Up @@ -253,7 +253,7 @@ const onEditDialogCancel = () => {
</option>
</select>
<Textarea v-else-if="props.editModel[key as keyof RowType] === 'textarea'" :name="key"
v-model.trim="editDialogItem[key]" required class="col-8" />
v-model.trim="editDialogItem[key]" class="col-8" />
<span v-else>{{ editDialogItem[key] }}</span>
</div>
</form>
Expand Down
36 changes: 21 additions & 15 deletions migrations/.snapshot-cathedral.json
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"length": 255,
"mappedType": "string"
}
Expand Down Expand Up @@ -823,7 +823,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"enumItems": [
"MUST",
"SHOULD",
Expand Down Expand Up @@ -1490,7 +1490,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"enumItems": [
"MUST",
"SHOULD",
Expand Down Expand Up @@ -1842,7 +1842,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"enumItems": [
"Business Rule",
"Physical Law",
Expand Down Expand Up @@ -2084,7 +2084,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"enumItems": [
"Client",
"Vendor"
Expand All @@ -2097,7 +2097,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"enumItems": [
"Key Stakeholder",
"Shadow Influencer",
Expand Down Expand Up @@ -2366,7 +2366,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"enumItems": [
"MUST",
"SHOULD",
Expand All @@ -2381,7 +2381,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"mappedType": "uuid"
},
"scope": {
Expand Down Expand Up @@ -2420,7 +2420,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"mappedType": "uuid"
},
"trigger_id": {
Expand All @@ -2429,7 +2429,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"mappedType": "uuid"
},
"main_success_scenario": {
Expand All @@ -2448,7 +2448,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"mappedType": "uuid"
},
"extensions": {
Expand Down Expand Up @@ -2512,6 +2512,7 @@
"id"
],
"referencedTableName": "public.stakeholder",
"deleteRule": "set null",
"updateRule": "cascade"
},
"use_case_precondition_id_foreign": {
Expand All @@ -2524,6 +2525,7 @@
"id"
],
"referencedTableName": "public.assumption",
"deleteRule": "set null",
"updateRule": "cascade"
},
"use_case_success_guarantee_id_foreign": {
Expand All @@ -2536,6 +2538,7 @@
"id"
],
"referencedTableName": "public.effect",
"deleteRule": "set null",
"updateRule": "cascade"
}
},
Expand Down Expand Up @@ -2608,7 +2611,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"enumItems": [
"MUST",
"SHOULD",
Expand All @@ -2623,7 +2626,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"mappedType": "uuid"
},
"functional_behavior_id": {
Expand All @@ -2632,7 +2635,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"mappedType": "uuid"
},
"outcome_id": {
Expand All @@ -2641,7 +2644,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"mappedType": "uuid"
}
},
Expand Down Expand Up @@ -2695,6 +2698,7 @@
"id"
],
"referencedTableName": "public.stakeholder",
"deleteRule": "set null",
"updateRule": "cascade"
},
"user_story_functional_behavior_id_foreign": {
Expand All @@ -2707,6 +2711,7 @@
"id"
],
"referencedTableName": "public.functional_behavior",
"deleteRule": "set null",
"updateRule": "cascade"
},
"user_story_outcome_id_foreign": {
Expand All @@ -2719,6 +2724,7 @@
"id"
],
"referencedTableName": "public.outcome",
"deleteRule": "set null",
"updateRule": "cascade"
}
},
Expand Down
89 changes: 89 additions & 0 deletions migrations/Migration20240928152521.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { Migration } from '@mikro-orm/migrations';

export class Migration20240928152521 extends Migration {

override async up(): Promise<void> {
this.addSql(`alter table "use_case" drop constraint "use_case_primary_actor_id_foreign";`);
this.addSql(`alter table "use_case" drop constraint "use_case_precondition_id_foreign";`);
this.addSql(`alter table "use_case" drop constraint "use_case_success_guarantee_id_foreign";`);

this.addSql(`alter table "user_story" drop constraint "user_story_primary_actor_id_foreign";`);
this.addSql(`alter table "user_story" drop constraint "user_story_functional_behavior_id_foreign";`);
this.addSql(`alter table "user_story" drop constraint "user_story_outcome_id_foreign";`);

this.addSql(`alter table "person" alter column "email" type varchar(255) using ("email"::varchar(255));`);
this.addSql(`alter table "person" alter column "email" drop not null;`);

this.addSql(`alter table "use_case" alter column "primary_actor_id" drop default;`);
this.addSql(`alter table "use_case" alter column "primary_actor_id" type uuid using ("primary_actor_id"::text::uuid);`);
this.addSql(`alter table "use_case" alter column "primary_actor_id" drop not null;`);
this.addSql(`alter table "use_case" alter column "precondition_id" drop default;`);
this.addSql(`alter table "use_case" alter column "precondition_id" type uuid using ("precondition_id"::text::uuid);`);
this.addSql(`alter table "use_case" alter column "precondition_id" drop not null;`);
this.addSql(`alter table "use_case" alter column "trigger_id" drop default;`);
this.addSql(`alter table "use_case" alter column "trigger_id" type uuid using ("trigger_id"::text::uuid);`);
this.addSql(`alter table "use_case" alter column "trigger_id" drop not null;`);
this.addSql(`alter table "use_case" alter column "success_guarantee_id" drop default;`);
this.addSql(`alter table "use_case" alter column "success_guarantee_id" type uuid using ("success_guarantee_id"::text::uuid);`);
this.addSql(`alter table "use_case" alter column "success_guarantee_id" drop not null;`);
this.addSql(`alter table "use_case" add constraint "use_case_primary_actor_id_foreign" foreign key ("primary_actor_id") references "stakeholder" ("id") on update cascade on delete set null;`);
this.addSql(`alter table "use_case" add constraint "use_case_precondition_id_foreign" foreign key ("precondition_id") references "assumption" ("id") on update cascade on delete set null;`);
this.addSql(`alter table "use_case" add constraint "use_case_success_guarantee_id_foreign" foreign key ("success_guarantee_id") references "effect" ("id") on update cascade on delete set null;`);

this.addSql(`alter table "user_story" alter column "primary_actor_id" drop default;`);
this.addSql(`alter table "user_story" alter column "primary_actor_id" type uuid using ("primary_actor_id"::text::uuid);`);
this.addSql(`alter table "user_story" alter column "primary_actor_id" drop not null;`);
this.addSql(`alter table "user_story" alter column "functional_behavior_id" drop default;`);
this.addSql(`alter table "user_story" alter column "functional_behavior_id" type uuid using ("functional_behavior_id"::text::uuid);`);
this.addSql(`alter table "user_story" alter column "functional_behavior_id" drop not null;`);
this.addSql(`alter table "user_story" alter column "outcome_id" drop default;`);
this.addSql(`alter table "user_story" alter column "outcome_id" type uuid using ("outcome_id"::text::uuid);`);
this.addSql(`alter table "user_story" alter column "outcome_id" drop not null;`);
this.addSql(`alter table "user_story" add constraint "user_story_primary_actor_id_foreign" foreign key ("primary_actor_id") references "stakeholder" ("id") on update cascade on delete set null;`);
this.addSql(`alter table "user_story" add constraint "user_story_functional_behavior_id_foreign" foreign key ("functional_behavior_id") references "functional_behavior" ("id") on update cascade on delete set null;`);
this.addSql(`alter table "user_story" add constraint "user_story_outcome_id_foreign" foreign key ("outcome_id") references "outcome" ("id") on update cascade on delete set null;`);
}

override async down(): Promise<void> {
this.addSql(`alter table "use_case" drop constraint "use_case_primary_actor_id_foreign";`);
this.addSql(`alter table "use_case" drop constraint "use_case_precondition_id_foreign";`);
this.addSql(`alter table "use_case" drop constraint "use_case_success_guarantee_id_foreign";`);

this.addSql(`alter table "user_story" drop constraint "user_story_primary_actor_id_foreign";`);
this.addSql(`alter table "user_story" drop constraint "user_story_functional_behavior_id_foreign";`);
this.addSql(`alter table "user_story" drop constraint "user_story_outcome_id_foreign";`);

this.addSql(`alter table "person" alter column "email" type varchar(255) using ("email"::varchar(255));`);
this.addSql(`alter table "person" alter column "email" set not null;`);

this.addSql(`alter table "use_case" alter column "primary_actor_id" drop default;`);
this.addSql(`alter table "use_case" alter column "primary_actor_id" type uuid using ("primary_actor_id"::text::uuid);`);
this.addSql(`alter table "use_case" alter column "primary_actor_id" set not null;`);
this.addSql(`alter table "use_case" alter column "precondition_id" drop default;`);
this.addSql(`alter table "use_case" alter column "precondition_id" type uuid using ("precondition_id"::text::uuid);`);
this.addSql(`alter table "use_case" alter column "precondition_id" set not null;`);
this.addSql(`alter table "use_case" alter column "trigger_id" drop default;`);
this.addSql(`alter table "use_case" alter column "trigger_id" type uuid using ("trigger_id"::text::uuid);`);
this.addSql(`alter table "use_case" alter column "trigger_id" set not null;`);
this.addSql(`alter table "use_case" alter column "success_guarantee_id" drop default;`);
this.addSql(`alter table "use_case" alter column "success_guarantee_id" type uuid using ("success_guarantee_id"::text::uuid);`);
this.addSql(`alter table "use_case" alter column "success_guarantee_id" set not null;`);
this.addSql(`alter table "use_case" add constraint "use_case_primary_actor_id_foreign" foreign key ("primary_actor_id") references "stakeholder" ("id") on update cascade;`);
this.addSql(`alter table "use_case" add constraint "use_case_precondition_id_foreign" foreign key ("precondition_id") references "assumption" ("id") on update cascade;`);
this.addSql(`alter table "use_case" add constraint "use_case_success_guarantee_id_foreign" foreign key ("success_guarantee_id") references "effect" ("id") on update cascade;`);

this.addSql(`alter table "user_story" alter column "primary_actor_id" drop default;`);
this.addSql(`alter table "user_story" alter column "primary_actor_id" type uuid using ("primary_actor_id"::text::uuid);`);
this.addSql(`alter table "user_story" alter column "primary_actor_id" set not null;`);
this.addSql(`alter table "user_story" alter column "functional_behavior_id" drop default;`);
this.addSql(`alter table "user_story" alter column "functional_behavior_id" type uuid using ("functional_behavior_id"::text::uuid);`);
this.addSql(`alter table "user_story" alter column "functional_behavior_id" set not null;`);
this.addSql(`alter table "user_story" alter column "outcome_id" drop default;`);
this.addSql(`alter table "user_story" alter column "outcome_id" type uuid using ("outcome_id"::text::uuid);`);
this.addSql(`alter table "user_story" alter column "outcome_id" set not null;`);
this.addSql(`alter table "user_story" add constraint "user_story_primary_actor_id_foreign" foreign key ("primary_actor_id") references "stakeholder" ("id") on update cascade;`);
this.addSql(`alter table "user_story" add constraint "user_story_functional_behavior_id_foreign" foreign key ("functional_behavior_id") references "functional_behavior" ("id") on update cascade;`);
this.addSql(`alter table "user_story" add constraint "user_story_outcome_id_foreign" foreign key ("outcome_id") references "outcome" ("id") on update cascade;`);
}

}
46 changes: 23 additions & 23 deletions mikro-orm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ import dotenv from "dotenv";
import { type Options, PostgreSqlDriver } from '@mikro-orm/postgresql';
import { TsMorphMetadataProvider } from '@mikro-orm/reflection';
import { Migrator } from '@mikro-orm/migrations';
import AssumptionSchema from "./server/data/models/AssumptionSchema.js";
import ConstraintSchema from "./server/data/models/ConstraintSchema.js";
import EffectSchema from "./server/data/models/EffectSchema.js";
import EnvironmentComponentSchema from "./server/data/models/EnvironmentComponentSchema.js";
import FunctionalBehaviorSchema from "./server/data/models/FunctionalBehaviorSchema.js";
import GlossaryTermSchema from "./server/data/models/GlossaryTermSchema.js";
import HintSchema from "./server/data/models/HintSchema.js";
import InvariantSchema from "./server/data/models/InvariantSchema.js";
import JustificationSchema from "./server/data/models/JustificationSchema.js";
import LimitSchema from "./server/data/models/LimitSchema.js";
import NonFunctionalBehaviorSchema from "./server/data/models/NonFunctionalBehaviorSchema.js";
import ObstacleSchema from "./server/data/models/ObstacleSchema.js";
import OutcomeSchema from "./server/data/models/OutcomeSchema.js";
import PersonSchema from "./server/data/models/PersonSchema.js";
import ProductSchema from "./server/data/models/ProductSchema.js";
import SolutionSchema from "./server/data/models/SolutionSchema.js";
import StakeholderSchema from "./server/data/models/StakeholderSchema.js";
import UseCaseSchema from "./server/data/models/UseCaseSchema.js";
import UserStorySchema from "./server/data/models/UserStorySchema.js";
import SystemComponentSchema from "./server/data/models/SystemComponentSchema.js";
import OrganizationSchema from "./server/data/models/OrganizationSchema.js";
import AppUserOrganizationRoleSchema from "./server/data/models/AppUserOrganizationRoleSchema.js";
import AppUserSchema from "./server/data/models/AppUserSchema.js";
import AssumptionSchema from "./server/data/models/requirements/AssumptionSchema.js";
import ConstraintSchema from "./server/data/models/requirements/ConstraintSchema.js";
import EffectSchema from "./server/data/models/requirements/EffectSchema.js";
import EnvironmentComponentSchema from "./server/data/models/requirements/EnvironmentComponentSchema.js";
import FunctionalBehaviorSchema from "./server/data/models/requirements/FunctionalBehaviorSchema.js";
import GlossaryTermSchema from "./server/data/models/requirements/GlossaryTermSchema.js";
import HintSchema from "./server/data/models/requirements/HintSchema.js";
import InvariantSchema from "./server/data/models/requirements/InvariantSchema.js";
import JustificationSchema from "./server/data/models/requirements/JustificationSchema.js";
import LimitSchema from "./server/data/models/requirements/LimitSchema.js";
import NonFunctionalBehaviorSchema from "./server/data/models/requirements/NonFunctionalBehaviorSchema.js";
import ObstacleSchema from "./server/data/models/requirements/ObstacleSchema.js";
import OutcomeSchema from "./server/data/models/requirements/OutcomeSchema.js";
import PersonSchema from "./server/data/models/requirements/PersonSchema.js";
import ProductSchema from "./server/data/models/requirements/ProductSchema.js";
import SolutionSchema from "./server/data/models/application/SolutionSchema.js";
import StakeholderSchema from "./server/data/models/requirements/StakeholderSchema.js";
import UseCaseSchema from "./server/data/models/requirements/UseCaseSchema.js";
import UserStorySchema from "./server/data/models/requirements/UserStorySchema.js";
import SystemComponentSchema from "./server/data/models/requirements/SystemComponentSchema.js";
import OrganizationSchema from "./server/data/models/application/OrganizationSchema.js";
import AppUserOrganizationRoleSchema from "./server/data/models/application/AppUserOrganizationRoleSchema.js";
import AppUserSchema from "./server/data/models/application/AppUserSchema.js";

dotenv.config();
const config: Options = {
Expand Down
Loading
Loading