Skip to content

Commit

Permalink
Add new migration for billing (#66)
Browse files Browse the repository at this point in the history
* Add new migration for billing

* Fix column

* Add BTREE index for billing_instance_service_id

* Change order
  • Loading branch information
Sergey-weber authored Feb 1, 2024
1 parent 7a60dd5 commit 7f44147
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/db/migrations/20240124144536_add_billing_columns_to_tenants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {Knex} from 'knex';

export async function up(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;
ALTER TABLE tenants ADD COLUMN billing_instance_service_id VARCHAR(255) DEFAULT NULL;
ALTER TABLE tenants ADD COLUMN billing_started_at TIMESTAMPTZ DEFAULT NULL;
CREATE INDEX tenants_billing_instance_service_id_idx ON tenants USING BTREE (billing_instance_service_id);
`);
}

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

0 comments on commit 7f44147

Please sign in to comment.