Commit 1138ffcf authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Grant privilege for user on tables in migration

parent 5784b891
Pipeline #2356 passed with stages
in 21 seconds
import {MigrationInterface, QueryRunner} from "typeorm";
import { MigrationInterface, QueryRunner } from "typeorm";
export class initSchema1563573591949 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`CREATE TABLE "organization" ("id" text NOT NULL, "name" character varying(200) NOT NULL, "elasticSearchName" character varying(100), "description" text NOT NULL, "logo" text, CONSTRAINT "PK_472c1f99a32def1b0abb219cd67" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "link" ("id" text NOT NULL, "name" character varying(100), "url" character varying(300) NOT NULL, "organizationId" text, CONSTRAINT "PK_26206fb7186da72fbb9eaa3fac9" PRIMARY KEY ("id"))`);
await queryRunner.query(`ALTER TABLE "link" ADD CONSTRAINT "FK_afeaa57181e374e281c9a647eda" FOREIGN KEY ("organizationId") REFERENCES "organization"("id") ON DELETE CASCADE`);
}
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`CREATE TABLE "organization" ("id" text NOT NULL, "name" character varying(200) NOT NULL, "elasticSearchName" character varying(100), "description" text NOT NULL, "logo" text, CONSTRAINT "PK_472c1f99a32def1b0abb219cd67" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "link" ("id" text NOT NULL, "name" character varying(100), "url" character varying(300) NOT NULL, "organizationId" text, CONSTRAINT "PK_26206fb7186da72fbb9eaa3fac9" PRIMARY KEY ("id"))`);
await queryRunner.query(`ALTER TABLE "link" ADD CONSTRAINT "FK_afeaa57181e374e281c9a647eda" FOREIGN KEY ("organizationId") REFERENCES "organization"("id") ON DELETE CASCADE`);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE "link" DROP CONSTRAINT "FK_afeaa57181e374e281c9a647eda"`);
await queryRunner.query(`DROP TABLE "link"`);
await queryRunner.query(`DROP TABLE "organization"`);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE "link" DROP CONSTRAINT "FK_afeaa57181e374e281c9a647eda"`);
await queryRunner.query(`DROP TABLE "link"`);
await queryRunner.query(`DROP TABLE "organization"`);
}
}
......@@ -11,5 +11,4 @@ export class PutUUIDByDefaultInOrganizationModel1574772582441 implements Migrati
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE "organization" ALTER COLUMN "uuid" DROP DEFAULT`, undefined);
}
}
import { MigrationInterface, QueryRunner } from "typeorm";
export class GrantAccessTuUser1574849918251 implements MigrationInterface {
name = 'GrantAccessTuUser1574849918251';
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "user";`, undefined);
}
public async down(queryRunner: QueryRunner): Promise<any> {
}
}
......@@ -5,6 +5,7 @@ ADMIN_GROUP_NAME=<name of the admin group>
ACCESS_TOKEN_COOKIE_KEY=<cookie key where the access token will be stored>
POSTGRES_USER=<postgres user>
POSTGRES_PASSWORD=<postgres password>
POSTGRES_ADMIN_PASSWORD=<postgres superuser password>
POSTGRES_HOST=<postgres database host>
POSTGRES_PORT=<postgres database port>
POSTGRES_DB=<postgres db>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment