Skip to content

Commit

Permalink
Implemented Functionality entity and associated table (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlhaufe authored Jun 28, 2024
1 parent 5ed625f commit b84af5c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"Nuxtr.nuxtr-vscode",
"Vue.volar",
"EditorConfig.EditorConfig",
"github.vscode-github-actions"
"github.vscode-github-actions",
"AlexShen.classdiagram-ts"
]
}
}
Expand Down
4 changes: 3 additions & 1 deletion data/MigrationManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PGlite } from "@electric-sql/pglite";
import Migration from "./Migration";
import InitDatabase_00001 from "./migrations/00001-InitDatabase";
import Functionality_00002 from "./migrations/00002-Functionality";

type MigrationName = `${number}-${string}`

Expand All @@ -9,7 +10,8 @@ type MigrationName = `${number}-${string}`
*/
export default class MigrationManager {
private _migrations = new Map<MigrationName, typeof Migration>([
["00001-InitDatabase", InitDatabase_00001]
["00001-InitDatabase", InitDatabase_00001],
["00002-Functionality", Functionality_00002]
])

constructor(
Expand Down
2 changes: 1 addition & 1 deletion data/migrations/00001-InitDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default class InitDatabase_00001 extends Migration {
extensions VARCHAR(200) NOT NULL
)
INHERITS (scenario);
`
`

await db.exec(sql)
}
Expand Down
29 changes: 29 additions & 0 deletions data/migrations/00002-Functionality.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { PGliteInterface } from "@electric-sql/pglite";
import Migration from "../Migration";

export default class Functionality_00002 extends Migration {
override async up(db: PGliteInterface): Promise<void> {
const sql = `
CREATE TABLE cathedral.functionality (
-- Additional columns can be added here if needed
)
INHERITS (cathedral.behavior);
ALTER TABLE cathedral.functional_behavior INHERIT cathedral.functionality;
ALTER TABLE cathedral.non_functional_behavior INHERIT cathedral.functionality;
`

await db.exec(sql)
}
override async down(db: PGliteInterface): Promise<void> {
const sql = `
ALTER TABLE cathedral.functional_behavior NO INHERIT cathedral.behavior;
ALTER TABLE cathedral.non_functional_behavior NO INHERIT cathedral.behavior;
DROP TABLE cathedral.functionality;
`

await db.exec(sql)
}

}
8 changes: 5 additions & 3 deletions domain/FunctionalBehavior.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Behavior from "./Behavior";
import Functionality from "./Functionality";

/**
* Outcome produced by the system or one of its components
* FunctionalBehavior specifies what behavior the system should exhibit, i.e.,
* the actions that the system must perform.
* Generally expressed in the form "system must do <requirement>,"
*/
export default class FunctionalBehavior extends Behavior { }
export default class FunctionalBehavior extends Functionality { }
3 changes: 3 additions & 0 deletions domain/Functionality.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Behavior from "./Behavior";

export default class Functionality extends Behavior { }
9 changes: 7 additions & 2 deletions domain/NonFunctionalBehavior.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import Behavior from "./Behavior";
import Functionality from "./Functionality";

export default class NonFunctionalBehavior extends Behavior { }
/**
* NonFunctionalBehavior is a type of Behavior that is not directly related to the functionality of a system.
* It specifies how the system should behave, i.e., the qualities that the system must exhibit.
* Generally expressed in the form "system shall be <requirement>."
*/
export default class NonFunctionalBehavior extends Functionality { }

0 comments on commit b84af5c

Please sign in to comment.