mirror of
https://github.com/directus/directus.git
synced 2026-02-11 17:24:56 -05:00
Fix string to text migrations for Oracle (#5462)
* Disabled string to text migrations for Oracle * Added oracle specific alter table migrations * Added notNull parameter to Oracle alter function * Wrapped notNull in if * Removed public oracle column alter function
This commit is contained in:
@@ -1,12 +1,31 @@
|
||||
import { Knex } from 'knex';
|
||||
import env from '../../env';
|
||||
|
||||
async function oracleAlterUrl(knex: Knex, type: string): Promise<void> {
|
||||
await knex.raw('ALTER TABLE "directus_webhooks" ADD "url__temp" ?', [knex.raw(type)]);
|
||||
await knex.raw('UPDATE "directus_webhooks" SET "url__temp"="url"');
|
||||
await knex.raw('ALTER TABLE "directus_webhooks" DROP COLUMN "url"');
|
||||
await knex.raw('ALTER TABLE "directus_webhooks" RENAME COLUMN "url__temp" TO "url"');
|
||||
await knex.raw('ALTER TABLE "directus_webhooks" MODIFY "url" NOT NULL');
|
||||
}
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
if (env.DB_CLIENT === 'oracledb') {
|
||||
await oracleAlterUrl(knex, 'CLOB');
|
||||
return;
|
||||
}
|
||||
|
||||
await knex.schema.alterTable('directus_webhooks', (table) => {
|
||||
table.text('url').alter();
|
||||
});
|
||||
}
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
if (env.DB_CLIENT === 'oracledb') {
|
||||
await oracleAlterUrl(knex, 'VARCHAR2(255)');
|
||||
return;
|
||||
}
|
||||
|
||||
await knex.schema.alterTable('directus_webhooks', (table) => {
|
||||
table.string('url').alter();
|
||||
});
|
||||
|
||||
@@ -1,12 +1,31 @@
|
||||
import { Knex } from 'knex';
|
||||
import env from '../../env';
|
||||
|
||||
async function oracleAlterCollections(knex: Knex, type: string): Promise<void> {
|
||||
await knex.raw('ALTER TABLE "directus_webhooks" ADD "collections__temp" ?', [knex.raw(type)]);
|
||||
await knex.raw('UPDATE "directus_webhooks" SET "collections__temp"="collections"');
|
||||
await knex.raw('ALTER TABLE "directus_webhooks" DROP COLUMN "collections"');
|
||||
await knex.raw('ALTER TABLE "directus_webhooks" RENAME COLUMN "collections__temp" TO "collections"');
|
||||
await knex.raw('ALTER TABLE "directus_webhooks" MODIFY "collections" NOT NULL');
|
||||
}
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
if (env.DB_CLIENT === 'oracledb') {
|
||||
await oracleAlterCollections(knex, 'CLOB');
|
||||
return;
|
||||
}
|
||||
|
||||
await knex.schema.alterTable('directus_webhooks', (table) => {
|
||||
table.text('collections').alter();
|
||||
});
|
||||
}
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
if (env.DB_CLIENT === 'oracledb') {
|
||||
await oracleAlterCollections(knex, 'VARCHAR2(255)');
|
||||
return;
|
||||
}
|
||||
|
||||
await knex.schema.alterTable('directus_webhooks', (table) => {
|
||||
table.string('collections').alter();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user