Skip to content

Commit

Permalink
Add two billing migrations (#89)
Browse files Browse the repository at this point in the history
* Add two billing migrations

* Fix name colummn
  • Loading branch information
Sergey-weber authored Mar 12, 2024
1 parent 0e32a0a commit 4fa8927
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/db/migrations/20240311145834_delete_some_billing_columns.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Knex} from 'knex';

export async function up(knex: Knex): Promise<void> {
return knex.raw(`
ALTER TABLE tenants DROP COLUMN billing_account_id;
ALTER TABLE tenants DROP COLUMN billing_rate;
DROP TYPE BILLING_RATE_TYPE;
`);
}

export async function down(knex: Knex): Promise<void> {
return knex.raw(`
CREATE TYPE BILLING_RATE_TYPE AS ENUM ('community', 'business');
ALTER TABLE tenants ADD COLUMN billing_rate BILLING_RATE_TYPE NOT NULL DEFAULT('community');
ALTER TABLE tenants ADD COLUMN billing_account_id VARCHAR(255) DEFAULT NULL;
`);
}
25 changes: 25 additions & 0 deletions src/db/migrations/20240311150016_add_new_billing_columns.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {Knex} from 'knex';

export async function up(knex: Knex): Promise<void> {
return knex.raw(`
ALTER TABLE tenants
ADD COLUMN billing_paused_by_user BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE tenants
ADD COLUMN billing_instance_service_is_active BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE tenants ADD COLUMN billing_ended_at TIMESTAMPTZ DEFAULT NULL;
`);
}

export async function down(knex: Knex): Promise<void> {
return knex.raw(`
ALTER TABLE tenants DROP COLUMN billing_ended_at;
ALTER TABLE tenants
DROP COLUMN billing_instance_service_is_active;
ALTER TABLE tenants
DROP COLUMN billing_paused_by_user;
`);
}

0 comments on commit 4fa8927

Please sign in to comment.