added support for sqlite
Signed-off-by: Lykke Axlin <lykkeaxlin@hotmail.com> Co-authored-by: klaraab <klarabroman@live.se>
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
exports.up = function up(knex) {
|
||||
return knex.raw(`
|
||||
CREATE OR REPLACE FUNCTION update_timestamp() RETURNS TRIGGER
|
||||
LANGUAGE plpgsql
|
||||
AS
|
||||
$$
|
||||
BEGIN
|
||||
NEW.updated_at = CURRENT_TIMESTAMP;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$;
|
||||
`);
|
||||
};
|
||||
|
||||
exports.down = function down(knex) {
|
||||
return knex.raw(`
|
||||
DROP FUNCTION IF EXISTS update_timestamp() CASCADE;
|
||||
`);
|
||||
};
|
||||
+15
-11
@@ -17,8 +17,12 @@
|
||||
exports.up = async function up(knex) {
|
||||
await knex.schema.createTable('metadata', table => {
|
||||
table.comment('The table of Bazaar metadata');
|
||||
table
|
||||
.text('entity_ref')
|
||||
.notNullable()
|
||||
.unique()
|
||||
.comment('The ref of the entity');
|
||||
table.text('name').notNullable().comment('The name of the entity');
|
||||
table.text('entity_ref').notNullable().comment('The ref of the entity');
|
||||
table
|
||||
.text('community')
|
||||
.comment('Link to where the community can discuss ideas');
|
||||
@@ -31,20 +35,20 @@ exports.up = async function up(knex) {
|
||||
.defaultTo('proposed')
|
||||
.notNullable()
|
||||
.comment('The status of the Bazaar project');
|
||||
table.timestamps(true, true);
|
||||
table
|
||||
.text('updated_at')
|
||||
.notNullable()
|
||||
.comment('Timestamp on ISO 8601 format when entity was last updated');
|
||||
});
|
||||
|
||||
await knex.raw(`
|
||||
CREATE TRIGGER update_timestamp
|
||||
BEFORE UPDATE
|
||||
ON metadata
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE update_timestamp();
|
||||
`);
|
||||
|
||||
await knex.schema.createTable('members', table => {
|
||||
table.comment('The table of Bazaar members');
|
||||
table.text('entity_ref').notNullable().comment('The ref of the entity');
|
||||
table
|
||||
.text('entity_ref')
|
||||
.notNullable()
|
||||
.references('metadata.entity_ref')
|
||||
.onDelete('CASCADE')
|
||||
.comment('The ref of the entity');
|
||||
table.text('user_id').notNullable().comment('The user id of the member');
|
||||
table
|
||||
.dateTime('join_date')
|
||||
Reference in New Issue
Block a user