-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41fa13e
commit f952e92
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
database/src/migrations/20211109101500_update_report_attachment_description.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,37 @@ | ||
import * as Knex from 'knex'; | ||
|
||
const DB_SCHEMA = process.env.DB_SCHEMA; | ||
|
||
/** | ||
* Add a new record to the `proprietor_type` lookup table. | ||
* | ||
* @export | ||
* @param {Knex} knex | ||
* @return {*} {Promise<void>} | ||
*/ | ||
export async function up(knex: Knex): Promise<void> { | ||
await knex.raw(` | ||
SET schema '${DB_SCHEMA}'; | ||
SET search_path = public, biohub_dapi_v1; | ||
DROP VIEW if exists project_report_attachment; | ||
DROP VIEW if exists survey_report_attachment; | ||
SET search_path = ${DB_SCHEMA}; | ||
ALTER TABLE project_report_attachment ALTER COLUMN description TYPE varchar(3000); | ||
ALTER TABLE survey_report_attachment ALTER COLUMN description TYPE varchar(3000); | ||
SET search_path = biohub_dapi_v1; | ||
SET ROLE biohub_api; | ||
CREATE OR REPLACE VIEW project_report_attachment as SELECT * FROM ${DB_SCHEMA}.project_report_attachment; | ||
CREATE OR REPLACE VIEW survey_report_attachment as SELECT * FROM ${DB_SCHEMA}.survey_report_attachment; | ||
SET ROLE postgres; | ||
`); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.raw(''); | ||
} |