zarsa
2 years ago
5 changed files with 72 additions and 15 deletions
@ -0,0 +1,19 @@ |
|||||||
|
import { DataSource, DataSourceOptions } from 'typeorm'; |
||||||
|
|
||||||
|
export const dataSourceOptions: DataSourceOptions = { |
||||||
|
type: 'mssql', |
||||||
|
host: '193.176.240.223\\sql2017', |
||||||
|
port: 1433, |
||||||
|
username: 'sa', |
||||||
|
password: 'Zar@Sql2017#1397', |
||||||
|
database: 'TirebanClub', |
||||||
|
entities: ['dist/**/*.entity{.ts,.js}'], |
||||||
|
synchronize: true, |
||||||
|
options: { |
||||||
|
trustServerCertificate: true, |
||||||
|
}, |
||||||
|
migrations: ['dist/db/migrations/*.js'], |
||||||
|
requestTimeout: 300000, |
||||||
|
}; |
||||||
|
const dataSource = new DataSource(dataSourceOptions); |
||||||
|
export default dataSource; |
@ -0,0 +1,43 @@ |
|||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm'; |
||||||
|
|
||||||
|
export class Refactoring1685871985306 implements MigrationInterface { |
||||||
|
name = 'Refactoring1685871985306'; |
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> { |
||||||
|
await queryRunner.query( |
||||||
|
`CREATE TABLE "group" ("id" int NOT NULL IDENTITY(1,1), "name" nvarchar(255) NOT NULL, CONSTRAINT "PK_256aa0fda9b1de1a73ee0b7106b" PRIMARY KEY ("id"))`, |
||||||
|
); |
||||||
|
await queryRunner.query( |
||||||
|
`CREATE TABLE "person_groups_group" ("personId" int NOT NULL, "groupId" int NOT NULL, CONSTRAINT "PK_2ee7c7f82940eb58121d88a0176" PRIMARY KEY ("personId", "groupId"))`, |
||||||
|
); |
||||||
|
await queryRunner.query( |
||||||
|
`CREATE INDEX "IDX_36e53832ea1beefb3de6cff976" ON "person_groups_group" ("personId") `, |
||||||
|
); |
||||||
|
await queryRunner.query( |
||||||
|
`CREATE INDEX "IDX_267fc87e69a07e823de020a27e" ON "person_groups_group" ("groupId") `, |
||||||
|
); |
||||||
|
await queryRunner.query( |
||||||
|
`ALTER TABLE "person_groups_group" ADD CONSTRAINT "FK_36e53832ea1beefb3de6cff976b" FOREIGN KEY ("personId") REFERENCES "person"("id") ON DELETE CASCADE ON UPDATE CASCADE`, |
||||||
|
); |
||||||
|
await queryRunner.query( |
||||||
|
`ALTER TABLE "person_groups_group" ADD CONSTRAINT "FK_267fc87e69a07e823de020a27e7" FOREIGN KEY ("groupId") REFERENCES "group"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> { |
||||||
|
await queryRunner.query( |
||||||
|
`ALTER TABLE "person_groups_group" DROP CONSTRAINT "FK_267fc87e69a07e823de020a27e7"`, |
||||||
|
); |
||||||
|
await queryRunner.query( |
||||||
|
`ALTER TABLE "person_groups_group" DROP CONSTRAINT "FK_36e53832ea1beefb3de6cff976b"`, |
||||||
|
); |
||||||
|
await queryRunner.query( |
||||||
|
`DROP INDEX "IDX_267fc87e69a07e823de020a27e" ON "person_groups_group"`, |
||||||
|
); |
||||||
|
await queryRunner.query( |
||||||
|
`DROP INDEX "IDX_36e53832ea1beefb3de6cff976" ON "person_groups_group"`, |
||||||
|
); |
||||||
|
await queryRunner.query(`DROP TABLE "person_groups_group"`); |
||||||
|
await queryRunner.query(`DROP TABLE "group"`); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue