mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
feat: Add migration to add managed
column to credentials table (#12275)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Co-authored-by: Tomi Turtiainen <10324676+tomi@users.noreply.github.com>
This commit is contained in:
parent
bafac73eb5
commit
3cb7081446
|
@ -29,6 +29,14 @@ export class CredentialsEntity extends WithTimestampsAndStringId implements ICre
|
||||||
@OneToMany('SharedCredentials', 'credentials')
|
@OneToMany('SharedCredentials', 'credentials')
|
||||||
shared: SharedCredentials[];
|
shared: SharedCredentials[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the credential is managed by n8n. We currently use this flag
|
||||||
|
* to provide OpenAI free credits on cloud. Managed credentials cannot be
|
||||||
|
* edited by the user.
|
||||||
|
*/
|
||||||
|
@Column({ default: false })
|
||||||
|
isManaged: boolean;
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
const { shared, ...rest } = this;
|
const { shared, ...rest } = this;
|
||||||
return rest;
|
return rest;
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||||
|
|
||||||
|
export class AddManagedColumnToCredentialsTable1734479635324 implements ReversibleMigration {
|
||||||
|
async up({ escape, runQuery, isSqlite }: MigrationContext) {
|
||||||
|
const tableName = escape.tableName('credentials_entity');
|
||||||
|
const columnName = escape.columnName('isManaged');
|
||||||
|
|
||||||
|
const defaultValue = isSqlite ? 0 : 'FALSE';
|
||||||
|
|
||||||
|
await runQuery(
|
||||||
|
`ALTER TABLE ${tableName} ADD COLUMN ${columnName} BOOLEAN NOT NULL DEFAULT ${defaultValue}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down({ escape, runQuery }: MigrationContext) {
|
||||||
|
const tableName = escape.tableName('credentials_entity');
|
||||||
|
const columnName = escape.columnName('isManaged');
|
||||||
|
|
||||||
|
await runQuery(`ALTER TABLE ${tableName} DROP COLUMN ${columnName}`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -74,6 +74,7 @@ import { AddDescriptionToTestDefinition1731404028106 } from '../common/173140402
|
||||||
import { CreateTestMetricTable1732271325258 } from '../common/1732271325258-CreateTestMetricTable';
|
import { CreateTestMetricTable1732271325258 } from '../common/1732271325258-CreateTestMetricTable';
|
||||||
import { CreateTestRun1732549866705 } from '../common/1732549866705-CreateTestRunTable';
|
import { CreateTestRun1732549866705 } from '../common/1732549866705-CreateTestRunTable';
|
||||||
import { AddMockedNodesColumnToTestDefinition1733133775640 } from '../common/1733133775640-AddMockedNodesColumnToTestDefinition';
|
import { AddMockedNodesColumnToTestDefinition1733133775640 } from '../common/1733133775640-AddMockedNodesColumnToTestDefinition';
|
||||||
|
import { AddManagedColumnToCredentialsTable1734479635324 } from '../common/1734479635324-AddManagedColumnToCredentialsTable';
|
||||||
|
|
||||||
export const mysqlMigrations: Migration[] = [
|
export const mysqlMigrations: Migration[] = [
|
||||||
InitialMigration1588157391238,
|
InitialMigration1588157391238,
|
||||||
|
@ -150,4 +151,5 @@ export const mysqlMigrations: Migration[] = [
|
||||||
CreateTestMetricTable1732271325258,
|
CreateTestMetricTable1732271325258,
|
||||||
CreateTestRun1732549866705,
|
CreateTestRun1732549866705,
|
||||||
AddMockedNodesColumnToTestDefinition1733133775640,
|
AddMockedNodesColumnToTestDefinition1733133775640,
|
||||||
|
AddManagedColumnToCredentialsTable1734479635324,
|
||||||
];
|
];
|
||||||
|
|
|
@ -74,6 +74,7 @@ import { AddDescriptionToTestDefinition1731404028106 } from '../common/173140402
|
||||||
import { CreateTestMetricTable1732271325258 } from '../common/1732271325258-CreateTestMetricTable';
|
import { CreateTestMetricTable1732271325258 } from '../common/1732271325258-CreateTestMetricTable';
|
||||||
import { CreateTestRun1732549866705 } from '../common/1732549866705-CreateTestRunTable';
|
import { CreateTestRun1732549866705 } from '../common/1732549866705-CreateTestRunTable';
|
||||||
import { AddMockedNodesColumnToTestDefinition1733133775640 } from '../common/1733133775640-AddMockedNodesColumnToTestDefinition';
|
import { AddMockedNodesColumnToTestDefinition1733133775640 } from '../common/1733133775640-AddMockedNodesColumnToTestDefinition';
|
||||||
|
import { AddManagedColumnToCredentialsTable1734479635324 } from '../common/1734479635324-AddManagedColumnToCredentialsTable';
|
||||||
|
|
||||||
export const postgresMigrations: Migration[] = [
|
export const postgresMigrations: Migration[] = [
|
||||||
InitialMigration1587669153312,
|
InitialMigration1587669153312,
|
||||||
|
@ -150,4 +151,5 @@ export const postgresMigrations: Migration[] = [
|
||||||
CreateTestMetricTable1732271325258,
|
CreateTestMetricTable1732271325258,
|
||||||
CreateTestRun1732549866705,
|
CreateTestRun1732549866705,
|
||||||
AddMockedNodesColumnToTestDefinition1733133775640,
|
AddMockedNodesColumnToTestDefinition1733133775640,
|
||||||
|
AddManagedColumnToCredentialsTable1734479635324,
|
||||||
];
|
];
|
||||||
|
|
|
@ -71,6 +71,7 @@ import { CreateTestDefinitionTable1730386903556 } from '../common/1730386903556-
|
||||||
import { CreateTestMetricTable1732271325258 } from '../common/1732271325258-CreateTestMetricTable';
|
import { CreateTestMetricTable1732271325258 } from '../common/1732271325258-CreateTestMetricTable';
|
||||||
import { CreateTestRun1732549866705 } from '../common/1732549866705-CreateTestRunTable';
|
import { CreateTestRun1732549866705 } from '../common/1732549866705-CreateTestRunTable';
|
||||||
import { AddMockedNodesColumnToTestDefinition1733133775640 } from '../common/1733133775640-AddMockedNodesColumnToTestDefinition';
|
import { AddMockedNodesColumnToTestDefinition1733133775640 } from '../common/1733133775640-AddMockedNodesColumnToTestDefinition';
|
||||||
|
import { AddManagedColumnToCredentialsTable1734479635324 } from '../common/1734479635324-AddManagedColumnToCredentialsTable';
|
||||||
|
|
||||||
const sqliteMigrations: Migration[] = [
|
const sqliteMigrations: Migration[] = [
|
||||||
InitialMigration1588102412422,
|
InitialMigration1588102412422,
|
||||||
|
@ -144,6 +145,7 @@ const sqliteMigrations: Migration[] = [
|
||||||
CreateTestMetricTable1732271325258,
|
CreateTestMetricTable1732271325258,
|
||||||
CreateTestRun1732549866705,
|
CreateTestRun1732549866705,
|
||||||
AddMockedNodesColumnToTestDefinition1733133775640,
|
AddMockedNodesColumnToTestDefinition1733133775640,
|
||||||
|
AddManagedColumnToCredentialsTable1734479635324,
|
||||||
];
|
];
|
||||||
|
|
||||||
export { sqliteMigrations };
|
export { sqliteMigrations };
|
||||||
|
|
Loading…
Reference in a new issue