@reachu/database 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
+ import AuditedModel from './AuditedModel';
1
2
  import Category from './Category';
2
- export default class Subcategory {
3
+ export default class Subcategory extends AuditedModel {
3
4
  id: number;
5
+ deletedAt: Date;
4
6
  name: string;
5
7
  category: Category;
6
8
  static getCacheKey: () => string;
@@ -13,14 +13,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const typeorm_1 = require("typeorm");
16
+ const AuditedModel_1 = __importDefault(require("./AuditedModel"));
16
17
  const Category_1 = __importDefault(require("./Category"));
17
- let Subcategory = class Subcategory {
18
+ let Subcategory = class Subcategory extends AuditedModel_1.default {
18
19
  };
19
20
  Subcategory.getCacheKey = () => 'SUBCATEGORIES';
20
21
  __decorate([
21
22
  typeorm_1.PrimaryGeneratedColumn(),
22
23
  __metadata("design:type", Number)
23
24
  ], Subcategory.prototype, "id", void 0);
25
+ __decorate([
26
+ typeorm_1.DeleteDateColumn(),
27
+ __metadata("design:type", Date)
28
+ ], Subcategory.prototype, "deletedAt", void 0);
24
29
  __decorate([
25
30
  typeorm_1.Column('varchar'),
26
31
  __metadata("design:type", String)
@@ -1 +1 @@
1
- {"version":3,"file":"Subcategory.js","sourceRoot":"","sources":["../../src/entity/Subcategory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qCAA4E;AAC5E,0DAAkC;AAGlC,IAAqB,WAAW,GAAhC,MAAqB,WAAW;CAW/B,CAAA;AADQ,uBAAW,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC;AAR3C;IADC,gCAAsB,EAAE;;uCACd;AAGX;IADC,gBAAM,CAAC,SAAS,CAAC;;yCACL;AAGb;IADC,mBAAS,CAAC,GAAG,EAAE,CAAC,kBAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;8BACvE,kBAAQ;6CAAC;AARA,WAAW;IAD/B,gBAAM,EAAE;GACY,WAAW,CAW/B;kBAXoB,WAAW"}
1
+ {"version":3,"file":"Subcategory.js","sourceRoot":"","sources":["../../src/entity/Subcategory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qCAA8F;AAC9F,kEAA0C;AAC1C,0DAAkC;AAGlC,IAAqB,WAAW,GAAhC,MAAqB,WAAY,SAAQ,sBAAY;CAcpD,CAAA;AADQ,uBAAW,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC;AAX3C;IADC,gCAAsB,EAAE;;uCACd;AAGX;IADC,0BAAgB,EAAE;8BACR,IAAI;8CAAC;AAGhB;IADC,gBAAM,CAAC,SAAS,CAAC;;yCACL;AAGb;IADC,mBAAS,CAAC,GAAG,EAAE,CAAC,kBAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;8BACvE,kBAAQ;6CAAC;AAXA,WAAW;IAD/B,gBAAM,EAAE;GACY,WAAW,CAc/B;kBAdoB,WAAW"}
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class task1032V11677763068338 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.task1032V11677763068338 = void 0;
13
+ class task1032V11677763068338 {
14
+ constructor() {
15
+ this.name = 'task1032V11677763068338';
16
+ }
17
+ up(queryRunner) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ yield queryRunner.query(`CREATE TABLE \`category_images\` (\`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`id\` int NOT NULL AUTO_INCREMENT, \`deleted_at\` datetime(6) NULL, \`srcn\` varchar(255) NULL, \`slug\` varchar(255) NULL, \`name\` varchar(255) NULL, \`src\` varchar(255) NULL, \`alt\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
20
+ yield queryRunner.query(`CREATE TABLE \`product_attribute\` (\`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`id\` int NOT NULL AUTO_INCREMENT, \`deleted_at\` datetime(6) NULL, \`attribute_id\` int NULL, \`product_id\` int NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
21
+ yield queryRunner.query(`CREATE TABLE \`attribute\` (\`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`id\` int NOT NULL AUTO_INCREMENT, \`deleted_at\` datetime(6) NULL, \`name\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
22
+ yield queryRunner.query(`ALTER TABLE \`category\` ADD \`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)`);
23
+ yield queryRunner.query(`ALTER TABLE \`category\` ADD \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
24
+ yield queryRunner.query(`ALTER TABLE \`category\` ADD \`deleted_at\` datetime(6) NULL`);
25
+ yield queryRunner.query(`ALTER TABLE \`category\` ADD \`slug\` varchar(255) NULL`);
26
+ yield queryRunner.query(`ALTER TABLE \`category\` ADD \`menu_order\` int NULL`);
27
+ yield queryRunner.query(`ALTER TABLE \`category\` ADD \`category_images_id\` int NULL`);
28
+ yield queryRunner.query(`ALTER TABLE \`category\` ADD CONSTRAINT \`FK_e7068d526cfc9b60374476835ea\` FOREIGN KEY (\`category_images_id\`) REFERENCES \`category_images\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
29
+ yield queryRunner.query(`ALTER TABLE \`product_attribute\` ADD CONSTRAINT \`FK_3e2f6a0f059b619505f30b8e54f\` FOREIGN KEY (\`attribute_id\`) REFERENCES \`attribute\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
30
+ yield queryRunner.query(`ALTER TABLE \`product_attribute\` ADD CONSTRAINT \`FK_c8f119684d209b55cf5e8b42532\` FOREIGN KEY (\`product_id\`) REFERENCES \`product\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
31
+ });
32
+ }
33
+ down(queryRunner) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ yield queryRunner.query(`ALTER TABLE \`product_attribute\` DROP FOREIGN KEY \`FK_c8f119684d209b55cf5e8b42532\``);
36
+ yield queryRunner.query(`ALTER TABLE \`product_attribute\` DROP FOREIGN KEY \`FK_3e2f6a0f059b619505f30b8e54f\``);
37
+ yield queryRunner.query(`ALTER TABLE \`category\` DROP FOREIGN KEY \`FK_e7068d526cfc9b60374476835ea\``);
38
+ yield queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`category_images_id\``);
39
+ yield queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`menu_order\``);
40
+ yield queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`slug\``);
41
+ yield queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`deleted_at\``);
42
+ yield queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`updated_at\``);
43
+ yield queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`created_at\``);
44
+ yield queryRunner.query(`DROP TABLE \`attribute\``);
45
+ yield queryRunner.query(`DROP TABLE \`product_attribute\``);
46
+ yield queryRunner.query(`DROP TABLE \`category_images\``);
47
+ });
48
+ }
49
+ }
50
+ exports.task1032V11677763068338 = task1032V11677763068338;
51
+ //# sourceMappingURL=1677763068338-task-1032V1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1677763068338-task-1032V1.js","sourceRoot":"","sources":["../../src/migrations/1677763068338-task-1032V1.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,MAAa,uBAAuB;IAApC;QACE,SAAI,GAAG,yBAAyB,CAAC;IAqDnC,CAAC;IAnDc,EAAE,CAAC,WAAwB;;YACtC,MAAM,WAAW,CAAC,KAAK,CACrB,ybAAyb,CAC1b,CAAC;YACF,MAAM,WAAW,CAAC,KAAK,CACrB,qWAAqW,CACtW,CAAC;YACF,MAAM,WAAW,CAAC,KAAK,CACrB,yUAAyU,CAC1U,CAAC;YACF,MAAM,WAAW,CAAC,KAAK,CACrB,+FAA+F,CAChG,CAAC;YACF,MAAM,WAAW,CAAC,KAAK,CACrB,8HAA8H,CAC/H,CAAC;YACF,MAAM,WAAW,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC;YACxF,MAAM,WAAW,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;YACnF,MAAM,WAAW,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;YAChF,MAAM,WAAW,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC;YACxF,MAAM,WAAW,CAAC,KAAK,CACrB,8LAA8L,CAC/L,CAAC;YACF,MAAM,WAAW,CAAC,KAAK,CACrB,2LAA2L,CAC5L,CAAC;YACF,MAAM,WAAW,CAAC,KAAK,CACrB,uLAAuL,CACxL,CAAC;QACJ,CAAC;KAAA;IAEY,IAAI,CAAC,WAAwB;;YACxC,MAAM,WAAW,CAAC,KAAK,CACrB,uFAAuF,CACxF,CAAC;YACF,MAAM,WAAW,CAAC,KAAK,CACrB,uFAAuF,CACxF,CAAC;YACF,MAAM,WAAW,CAAC,KAAK,CACrB,8EAA8E,CAC/E,CAAC;YACF,MAAM,WAAW,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;YACvF,MAAM,WAAW,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;YAC/E,MAAM,WAAW,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;YACzE,MAAM,WAAW,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;YAC/E,MAAM,WAAW,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;YAC/E,MAAM,WAAW,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;YAC/E,MAAM,WAAW,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;YACpD,MAAM,WAAW,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;YAC5D,MAAM,WAAW,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAC5D,CAAC;KAAA;CACF;AAtDD,0DAsDC"}
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+ export declare class task1032V21677764464274 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.task1032V21677764464274 = void 0;
13
+ class task1032V21677764464274 {
14
+ constructor() {
15
+ this.name = 'task1032V21677764464274';
16
+ }
17
+ up(queryRunner) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ yield queryRunner.query(`ALTER TABLE \`subcategory\` ADD \`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)`);
20
+ yield queryRunner.query(`ALTER TABLE \`subcategory\` ADD \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
21
+ yield queryRunner.query(`ALTER TABLE \`subcategory\` ADD \`deleted_at\` datetime(6) NULL`);
22
+ });
23
+ }
24
+ down(queryRunner) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ yield queryRunner.query(`ALTER TABLE \`subcategory\` DROP COLUMN \`deleted_at\``);
27
+ yield queryRunner.query(`ALTER TABLE \`subcategory\` DROP COLUMN \`updated_at\``);
28
+ yield queryRunner.query(`ALTER TABLE \`subcategory\` DROP COLUMN \`created_at\``);
29
+ });
30
+ }
31
+ }
32
+ exports.task1032V21677764464274 = task1032V21677764464274;
33
+ //# sourceMappingURL=1677764464274-task-1032V2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1677764464274-task-1032V2.js","sourceRoot":"","sources":["../../src/migrations/1677764464274-task-1032V2.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,MAAa,uBAAuB;IAApC;QACI,SAAI,GAAG,yBAAyB,CAAA;IAcpC,CAAC;IAZgB,EAAE,CAAC,WAAwB;;YACpC,MAAM,WAAW,CAAC,KAAK,CAAC,kGAAkG,CAAC,CAAC;YAC5H,MAAM,WAAW,CAAC,KAAK,CAAC,iIAAiI,CAAC,CAAC;YAC3J,MAAM,WAAW,CAAC,KAAK,CAAC,iEAAiE,CAAC,CAAC;QAC/F,CAAC;KAAA;IAEY,IAAI,CAAC,WAAwB;;YACtC,MAAM,WAAW,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;YAClF,MAAM,WAAW,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;YAClF,MAAM,WAAW,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACtF,CAAC;KAAA;CAEJ;AAfD,0DAeC"}
@@ -1927,8 +1927,8 @@
1927
1927
  "affectsGlobalScope": false
1928
1928
  },
1929
1929
  "../src/entity/subcategory.ts": {
1930
- "version": "73b85383e0bd1ef6ed0a103cc3e247ea0f4507bbdafcaf78b38930c39c61e49b",
1931
- "signature": "7b2670d549ce3013f7fe122e1ee02009ee3b2995a7ba2af385527d2f02329012",
1930
+ "version": "26b02abbae1a4dd83bc9cfb040ad080a6083938f74557045e8e24a7d394ba782",
1931
+ "signature": "6bab357cec0125bbac6b707fb8c841355bedeb0c56fc4684822a90a7ca390fdb",
1932
1932
  "affectsGlobalScope": false
1933
1933
  },
1934
1934
  "../src/entity/category.ts": {
@@ -3001,6 +3001,16 @@
3001
3001
  "signature": "5c4edd69708ca8a11f2aa55bcf1acfb520678afefba346a893b7697974dbdb8b",
3002
3002
  "affectsGlobalScope": false
3003
3003
  },
3004
+ "../src/migrations/1677763068338-task-1032v1.ts": {
3005
+ "version": "6e09e6b6ce6e48e85bffe6b253207cec03a637250e194570e90b18573056c6d1",
3006
+ "signature": "a3a7ebedf800879ffa5e04d45d6a73ac216816a05ad67ab63e6671467950a5cf",
3007
+ "affectsGlobalScope": false
3008
+ },
3009
+ "../src/migrations/1677764464274-task-1032v2.ts": {
3010
+ "version": "9b976a871513072a917fe9486edcb2b1cfe06a00030bee40b4b240502c0a76ef",
3011
+ "signature": "0b0c73764a789c14efda2c2211880a22ecb26f1f57921327745ebb29dd3e317b",
3012
+ "affectsGlobalScope": false
3013
+ },
3004
3014
  "../src/migrations/execute/index.ts": {
3005
3015
  "version": "8b5bf13d095aeb57afd593adf3d799681176a13c327e2f77e0028e178c4ee3b9",
3006
3016
  "signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881",
@@ -5349,6 +5359,7 @@
5349
5359
  ],
5350
5360
  "../src/entity/subcategory.ts": [
5351
5361
  "../node_modules/typeorm/index.d.ts",
5362
+ "../src/entity/auditedmodel.ts",
5352
5363
  "../src/entity/category.ts"
5353
5364
  ],
5354
5365
  "../src/entity/user.ts": [
@@ -5583,6 +5594,12 @@
5583
5594
  "../src/migrations/1677706695399-promote_to_production_2023_01_03.ts": [
5584
5595
  "../node_modules/typeorm/index.d.ts"
5585
5596
  ],
5597
+ "../src/migrations/1677763068338-task-1032v1.ts": [
5598
+ "../node_modules/typeorm/index.d.ts"
5599
+ ],
5600
+ "../src/migrations/1677764464274-task-1032v2.ts": [
5601
+ "../node_modules/typeorm/index.d.ts"
5602
+ ],
5586
5603
  "../src/migrations/execute/index.ts": [
5587
5604
  "../src/config/connect.ts"
5588
5605
  ],
@@ -7805,6 +7822,7 @@
7805
7822
  "../src/entity/user.ts"
7806
7823
  ],
7807
7824
  "../src/entity/subcategory.ts": [
7825
+ "../src/entity/auditedmodel.ts",
7808
7826
  "../src/entity/category.ts"
7809
7827
  ],
7810
7828
  "../src/entity/user.ts": [
@@ -8013,6 +8031,12 @@
8013
8031
  "../src/migrations/1677706695399-promote_to_production_2023_01_03.ts": [
8014
8032
  "../node_modules/typeorm/index.d.ts"
8015
8033
  ],
8034
+ "../src/migrations/1677763068338-task-1032v1.ts": [
8035
+ "../node_modules/typeorm/index.d.ts"
8036
+ ],
8037
+ "../src/migrations/1677764464274-task-1032v2.ts": [
8038
+ "../node_modules/typeorm/index.d.ts"
8039
+ ],
8016
8040
  "../src/migrations/index.ts": [
8017
8041
  "../src/migrations/1628474597284-initialschema.ts",
8018
8042
  "../src/migrations/1630077596132-removemangopay.ts",
@@ -8734,6 +8758,8 @@
8734
8758
  "../src/migrations/1676558804200-task-1074v1.ts",
8735
8759
  "../src/migrations/1676656657956-task-1084v1.ts",
8736
8760
  "../src/migrations/1677706695399-promote_to_production_2023_01_03.ts",
8761
+ "../src/migrations/1677763068338-task-1032v1.ts",
8762
+ "../src/migrations/1677764464274-task-1032v2.ts",
8737
8763
  "../src/migrations/execute/index.ts",
8738
8764
  "../src/migrations/index.ts",
8739
8765
  "../src/repositories/index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reachu/database",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "reachu-database",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,8 +21,8 @@
21
21
  "author": "reachu",
22
22
  "license": "ISC",
23
23
  "dependencies": {
24
- "@reachu/logger": "1.0.2",
25
- "@reachu/utils": "1.0.2",
24
+ "@reachu/logger": "1.0.3",
25
+ "@reachu/utils": "1.0.3",
26
26
  "dotenv": "8.0.0",
27
27
  "express": "4.17.1",
28
28
  "mysql2": "1.5.2",
@@ -1,11 +1,15 @@
1
- import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm';
1
+ import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, DeleteDateColumn } from 'typeorm';
2
+ import AuditedModel from './AuditedModel';
2
3
  import Category from './Category';
3
4
 
4
5
  @Entity()
5
- export default class Subcategory {
6
+ export default class Subcategory extends AuditedModel {
6
7
  @PrimaryGeneratedColumn()
7
8
  id: number;
8
9
 
10
+ @DeleteDateColumn()
11
+ deletedAt: Date;
12
+
9
13
  @Column('varchar')
10
14
  name: string;
11
15
 
@@ -0,0 +1,57 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ export class task1032V11677763068338 implements MigrationInterface {
4
+ name = 'task1032V11677763068338';
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `CREATE TABLE \`category_images\` (\`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`id\` int NOT NULL AUTO_INCREMENT, \`deleted_at\` datetime(6) NULL, \`srcn\` varchar(255) NULL, \`slug\` varchar(255) NULL, \`name\` varchar(255) NULL, \`src\` varchar(255) NULL, \`alt\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`,
9
+ );
10
+ await queryRunner.query(
11
+ `CREATE TABLE \`product_attribute\` (\`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`id\` int NOT NULL AUTO_INCREMENT, \`deleted_at\` datetime(6) NULL, \`attribute_id\` int NULL, \`product_id\` int NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`,
12
+ );
13
+ await queryRunner.query(
14
+ `CREATE TABLE \`attribute\` (\`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`id\` int NOT NULL AUTO_INCREMENT, \`deleted_at\` datetime(6) NULL, \`name\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`,
15
+ );
16
+ await queryRunner.query(
17
+ `ALTER TABLE \`category\` ADD \`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)`,
18
+ );
19
+ await queryRunner.query(
20
+ `ALTER TABLE \`category\` ADD \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`,
21
+ );
22
+ await queryRunner.query(`ALTER TABLE \`category\` ADD \`deleted_at\` datetime(6) NULL`);
23
+ await queryRunner.query(`ALTER TABLE \`category\` ADD \`slug\` varchar(255) NULL`);
24
+ await queryRunner.query(`ALTER TABLE \`category\` ADD \`menu_order\` int NULL`);
25
+ await queryRunner.query(`ALTER TABLE \`category\` ADD \`category_images_id\` int NULL`);
26
+ await queryRunner.query(
27
+ `ALTER TABLE \`category\` ADD CONSTRAINT \`FK_e7068d526cfc9b60374476835ea\` FOREIGN KEY (\`category_images_id\`) REFERENCES \`category_images\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
28
+ );
29
+ await queryRunner.query(
30
+ `ALTER TABLE \`product_attribute\` ADD CONSTRAINT \`FK_3e2f6a0f059b619505f30b8e54f\` FOREIGN KEY (\`attribute_id\`) REFERENCES \`attribute\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
31
+ );
32
+ await queryRunner.query(
33
+ `ALTER TABLE \`product_attribute\` ADD CONSTRAINT \`FK_c8f119684d209b55cf5e8b42532\` FOREIGN KEY (\`product_id\`) REFERENCES \`product\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
34
+ );
35
+ }
36
+
37
+ public async down(queryRunner: QueryRunner): Promise<void> {
38
+ await queryRunner.query(
39
+ `ALTER TABLE \`product_attribute\` DROP FOREIGN KEY \`FK_c8f119684d209b55cf5e8b42532\``,
40
+ );
41
+ await queryRunner.query(
42
+ `ALTER TABLE \`product_attribute\` DROP FOREIGN KEY \`FK_3e2f6a0f059b619505f30b8e54f\``,
43
+ );
44
+ await queryRunner.query(
45
+ `ALTER TABLE \`category\` DROP FOREIGN KEY \`FK_e7068d526cfc9b60374476835ea\``,
46
+ );
47
+ await queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`category_images_id\``);
48
+ await queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`menu_order\``);
49
+ await queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`slug\``);
50
+ await queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`deleted_at\``);
51
+ await queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`updated_at\``);
52
+ await queryRunner.query(`ALTER TABLE \`category\` DROP COLUMN \`created_at\``);
53
+ await queryRunner.query(`DROP TABLE \`attribute\``);
54
+ await queryRunner.query(`DROP TABLE \`product_attribute\``);
55
+ await queryRunner.query(`DROP TABLE \`category_images\``);
56
+ }
57
+ }
@@ -0,0 +1,18 @@
1
+ import {MigrationInterface, QueryRunner} from "typeorm";
2
+
3
+ export class task1032V21677764464274 implements MigrationInterface {
4
+ name = 'task1032V21677764464274'
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(`ALTER TABLE \`subcategory\` ADD \`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)`);
8
+ await queryRunner.query(`ALTER TABLE \`subcategory\` ADD \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
9
+ await queryRunner.query(`ALTER TABLE \`subcategory\` ADD \`deleted_at\` datetime(6) NULL`);
10
+ }
11
+
12
+ public async down(queryRunner: QueryRunner): Promise<void> {
13
+ await queryRunner.query(`ALTER TABLE \`subcategory\` DROP COLUMN \`deleted_at\``);
14
+ await queryRunner.query(`ALTER TABLE \`subcategory\` DROP COLUMN \`updated_at\``);
15
+ await queryRunner.query(`ALTER TABLE \`subcategory\` DROP COLUMN \`created_at\``);
16
+ }
17
+
18
+ }