Address various code review comments.
Signed-off-by: Jussi Hallila <jussi@hallila.com>
This commit is contained in:
@@ -24,24 +24,28 @@ exports.up = async function up(knex) {
|
||||
table.comment(
|
||||
'The table for tech insight fact schemas. Containing a versioned data model definition for a collection of facts.',
|
||||
);
|
||||
table.increments('id').primary();
|
||||
table
|
||||
.text('ref')
|
||||
.text('id')
|
||||
.notNullable()
|
||||
.comment('Identifier of the fact retriever plugin/package');
|
||||
table
|
||||
.string('version')
|
||||
.notNullable()
|
||||
.comment('SemVer string defining the version of schema.');
|
||||
table
|
||||
.string('entityTypes')
|
||||
.nullable()
|
||||
.comment(
|
||||
'A comma separated collection of entity kinds the fact retriever providing this schema affects. Defaults to null, which means all entity kinds.',
|
||||
);
|
||||
table
|
||||
.text('schema')
|
||||
.notNullable()
|
||||
.comment(
|
||||
'Fact schema defining the values/types what this version of the fact would contain.',
|
||||
);
|
||||
|
||||
table.index('ref', 'fact_schema_ref_idx');
|
||||
table.index(['ref', 'version'], 'fact_schema_ref_version_idx');
|
||||
table.primary(['id', 'version']);
|
||||
table.index('id', 'fact_schema_id_idx');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -50,8 +54,7 @@ exports.up = async function up(knex) {
|
||||
*/
|
||||
exports.down = async function down(knex) {
|
||||
await knex.schema.alterTable('fact_schemas', table => {
|
||||
table.dropIndex([], 'fact_schema_ref_idx');
|
||||
table.dropIndex([], 'fact_schema_ref_version_idx');
|
||||
table.dropIndex([], 'fact_schema_id_idx');
|
||||
});
|
||||
await knex.schema.dropTable('fact_schemas');
|
||||
};
|
||||
|
||||
@@ -25,11 +25,7 @@ exports.up = async function up(knex) {
|
||||
'The table for tech insight fact collections. Contains facts for individual fact retriever namespace/ref.',
|
||||
);
|
||||
table
|
||||
.bigIncrements('index')
|
||||
.notNullable()
|
||||
.comment('An insert counter to ensure ordering');
|
||||
table
|
||||
.text('ref')
|
||||
.text('id')
|
||||
.notNullable()
|
||||
.comment('Unique identifier of the fact retriever plugin/package');
|
||||
table
|
||||
@@ -54,9 +50,13 @@ exports.up = async function up(knex) {
|
||||
'Values of the fact collection stored as key-value pairs in JSON format.',
|
||||
);
|
||||
|
||||
table.index('index', 'fact_index_idx');
|
||||
table.index('ref', 'fact_ref_idx');
|
||||
table.index(['ref', 'entity'], 'fact_ref_entity_idx');
|
||||
table
|
||||
.foreign(['id', 'version'])
|
||||
.references(['id', 'version'])
|
||||
.inTable('fact_schemas');
|
||||
|
||||
table.index(['id', 'entity'], 'fact_id_entity_idx');
|
||||
table.index('id', 'fact_id_idx');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -65,9 +65,8 @@ exports.up = async function up(knex) {
|
||||
*/
|
||||
exports.down = async function down(knex) {
|
||||
await knex.schema.alterTable('facts', table => {
|
||||
table.dropIndex([], 'facts_index_idx');
|
||||
table.dropIndex([], 'fact_ref_idx');
|
||||
table.dropIndex([], 'fact_ref_entity_idx');
|
||||
table.dropIndex([], 'fact_id_idx');
|
||||
table.dropIndex([], 'fact_id_entity_idx');
|
||||
});
|
||||
await knex.schema.dropTable('facts');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user