-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new migration for billing * Fix column * Add BTREE index for billing_instance_service_id * Change order
- Loading branch information
1 parent
7a60dd5
commit 7f44147
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/db/migrations/20240124144536_add_billing_columns_to_tenants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
`); | ||
} |