From b450ffaffb07aa546da27618aa7f88473a56aa86 Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Wed, 1 May 2024 11:43:09 +1000 Subject: [PATCH 1/3] refactor: change default route quota to unlimited for organizations --- .../20240501000000_organization_routequota.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 services/api/database/migrations/20240501000000_organization_routequota.js diff --git a/services/api/database/migrations/20240501000000_organization_routequota.js b/services/api/database/migrations/20240501000000_organization_routequota.js new file mode 100644 index 0000000000..98cb81ac4f --- /dev/null +++ b/services/api/database/migrations/20240501000000_organization_routequota.js @@ -0,0 +1,17 @@ +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.up = function(knex) { + return knex.schema + .raw(`ALTER TABLE organization ALTER quota_route SET DEFAULT -1;`) +}; + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.down = function(knex) { + return knex.schema + .raw(`ALTER TABLE organization ALTER quota_route SET DEFAULT 5;`) +}; From afb1a587d04d52d7be02360bdedd37f84be1fbc5 Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Thu, 9 May 2024 08:14:45 +1000 Subject: [PATCH 2/3] refactor: change all organization quota defaults to unlimited --- .../20240501000000_organization_quotas.js | 25 +++++++++++++++++++ .../20240501000000_organization_routequota.js | 17 ------------- 2 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 services/api/database/migrations/20240501000000_organization_quotas.js delete mode 100644 services/api/database/migrations/20240501000000_organization_routequota.js diff --git a/services/api/database/migrations/20240501000000_organization_quotas.js b/services/api/database/migrations/20240501000000_organization_quotas.js new file mode 100644 index 0000000000..128cef9614 --- /dev/null +++ b/services/api/database/migrations/20240501000000_organization_quotas.js @@ -0,0 +1,25 @@ +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.up = function(knex) { + return knex.schema + .raw(`ALTER TABLE organization ALTER quota_route SET DEFAULT -1;`) + .raw(`ALTER TABLE organization ALTER quota_project SET DEFAULT -1;`) + .raw(`ALTER TABLE organization ALTER quota_group SET DEFAULT -1;`) + .raw(`ALTER TABLE organization ALTER quota_notification SET DEFAULT -1;`) + .raw(`ALTER TABLE organization ALTER quota_environment SET DEFAULT -1;`) +}; + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.down = function(knex) { + return knex.schema + .raw(`ALTER TABLE organization ALTER quota_route SET DEFAULT 5;`) + .raw(`ALTER TABLE organization ALTER quota_project SET DEFAULT 1;`) + .raw(`ALTER TABLE organization ALTER quota_group SET DEFAULT 10;`) + .raw(`ALTER TABLE organization ALTER quota_notification SET DEFAULT 10;`) + .raw(`ALTER TABLE organization ALTER quota_environment SET DEFAULT 5;`) +}; diff --git a/services/api/database/migrations/20240501000000_organization_routequota.js b/services/api/database/migrations/20240501000000_organization_routequota.js deleted file mode 100644 index 98cb81ac4f..0000000000 --- a/services/api/database/migrations/20240501000000_organization_routequota.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @param { import("knex").Knex } knex - * @returns { Promise } - */ -exports.up = function(knex) { - return knex.schema - .raw(`ALTER TABLE organization ALTER quota_route SET DEFAULT -1;`) -}; - -/** - * @param { import("knex").Knex } knex - * @returns { Promise } - */ -exports.down = function(knex) { - return knex.schema - .raw(`ALTER TABLE organization ALTER quota_route SET DEFAULT 5;`) -}; From 5b11bc8857aba15118cb8a911dee48982009feae Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Mon, 13 May 2024 14:16:17 +1000 Subject: [PATCH 3/3] refactor: add created timestamp to organizations --- .../migrations/20240501000000_organization_quotas.js | 6 ++++++ services/api/src/typeDefs.js | 1 + 2 files changed, 7 insertions(+) diff --git a/services/api/database/migrations/20240501000000_organization_quotas.js b/services/api/database/migrations/20240501000000_organization_quotas.js index 128cef9614..773fa91636 100644 --- a/services/api/database/migrations/20240501000000_organization_quotas.js +++ b/services/api/database/migrations/20240501000000_organization_quotas.js @@ -9,6 +9,9 @@ exports.up = function(knex) { .raw(`ALTER TABLE organization ALTER quota_group SET DEFAULT -1;`) .raw(`ALTER TABLE organization ALTER quota_notification SET DEFAULT -1;`) .raw(`ALTER TABLE organization ALTER quota_environment SET DEFAULT -1;`) + .alterTable('organization', function (table) { + table.timestamp('created').defaultTo(knex.fn.now()); + }) }; /** @@ -22,4 +25,7 @@ exports.down = function(knex) { .raw(`ALTER TABLE organization ALTER quota_group SET DEFAULT 10;`) .raw(`ALTER TABLE organization ALTER quota_notification SET DEFAULT 10;`) .raw(`ALTER TABLE organization ALTER quota_environment SET DEFAULT 5;`) + .alterTable('organization', (table) => { + table.dropColumn('created'); + }) }; diff --git a/services/api/src/typeDefs.js b/services/api/src/typeDefs.js index 40f116ac0c..5f3a567c65 100644 --- a/services/api/src/typeDefs.js +++ b/services/api/src/typeDefs.js @@ -1109,6 +1109,7 @@ const typeDefs = gql` groups: [OrgGroupInterface] owners: [OrgUser] notifications(type: NotificationType): [Notification] + created: String } input AddOrganizationInput {