Merge pull request #3881 from backstage/freben/unbreak-sqlite

catalog-backend: unbreak sqlite in create-app repos
This commit is contained in:
Fredrik Adelöw
2020-12-30 10:38:53 +01:00
committed by GitHub
4 changed files with 11 additions and 21 deletions
@@ -20,16 +20,14 @@
* @param {import('knex')} knex
*/
exports.up = async function up(knex) {
// Drop constraints (Postgres)
try {
// SQLite does not support FK and PK
if (knex.client.config.client !== 'sqlite3') {
await knex.schema.alterTable('entities_search', table => {
table.dropForeign(['entity_id']);
});
await knex.schema.alterTable('entities', table => {
table.dropPrimary('entities_pkey');
});
} catch (e) {
// SQLite does not support FK and PK, carry on
}
await knex.schema.alterTable('entities', table => {
table.dropUnique([], 'entities_unique_name');
@@ -131,16 +129,14 @@ exports.up = async function up(knex) {
* @param {import('knex')} knex
*/
exports.down = async function down(knex) {
// Drop constraints (Postgres)
try {
// SQLite does not support FK and PK
if (knex.client.config.client !== 'sqlite3') {
await knex.schema.alterTable('entities_search', table => {
table.dropForeign(['entity_id']);
});
await knex.schema.alterTable('entities', table => {
table.dropPrimary('entities_pkey');
});
} catch (e) {
// SQLite does not support FK and PK, carry on
}
await knex.schema.alterTable('entities', table => {
table.dropUnique([], 'entities_unique_name');
@@ -20,12 +20,11 @@
* @param {import('knex')} knex
*/
exports.up = async function up(knex) {
try {
// Sqlite does not support alter column.
if (knex.client.config.client !== 'sqlite3') {
await knex.schema.alterTable('entities_search', table => {
table.text('value').nullable().alter();
});
} catch (e) {
// Sqlite does not support alter column.
}
};
@@ -33,11 +32,10 @@ exports.up = async function up(knex) {
* @param {import('knex')} knex
*/
exports.down = async function down(knex) {
try {
// Sqlite does not support alter column.
if (knex.client.config.client !== 'sqlite3') {
await knex.schema.alterTable('entities_search', table => {
table.string('value').nullable().alter();
});
} catch (e) {
// Sqlite does not support alter column.
}
};
@@ -30,12 +30,11 @@ exports.up = async function up(knex) {
),
});
try {
// SQLite does not support alter column
if (knex.client.config.client !== 'sqlite3') {
await knex.schema.alterTable('entities', table => {
table.text('full_name').notNullable().alter();
});
} catch (e) {
// SQLite does not support alter column, ignore
}
await knex.schema.alterTable('entities', table => {
@@ -40,10 +40,7 @@ exports.up = async function up(knex) {
table.dropColumn('spec');
});
// SQLite does not support ALTER COLUMN. Note that we do not use the try/
// catch method as in other migrations, because if the transaction is
// partially failed, it will further mess up the already messed-up
// statement below this.
// SQLite does not support ALTER COLUMN.
if (knex.client.config.client !== 'sqlite3') {
await knex.schema.alterTable('entities', table => {
table.text('data').notNullable().alter();