@reachu/database 1.0.1 → 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.
- package/dist/entity/Attribute.d.ts +8 -0
- package/dist/entity/Attribute.js +41 -0
- package/dist/entity/Attribute.js.map +1 -0
- package/dist/entity/Category.d.ts +7 -1
- package/dist/entity/Category.js +23 -1
- package/dist/entity/Category.js.map +1 -1
- package/dist/entity/CategoryImages.d.ts +12 -0
- package/dist/entity/CategoryImages.js +57 -0
- package/dist/entity/CategoryImages.js.map +1 -0
- package/dist/entity/Product.entity.d.ts +2 -0
- package/dist/entity/Product.entity.js +6 -0
- package/dist/entity/Product.entity.js.map +1 -1
- package/dist/entity/ProductAttribute.d.ts +9 -0
- package/dist/entity/ProductAttribute.js +49 -0
- package/dist/entity/ProductAttribute.js.map +1 -0
- package/dist/entity/Subcategory.d.ts +3 -1
- package/dist/entity/Subcategory.js +6 -1
- package/dist/entity/Subcategory.js.map +1 -1
- package/dist/entity/index.d.ts +4 -1
- package/dist/entity/index.js +7 -1
- package/dist/entity/index.js.map +1 -1
- package/dist/helpers/products/storage/search.d.ts +1 -0
- package/dist/migrations/1677706695399-promote_to_production_2023_01_03.d.ts +6 -0
- package/dist/migrations/1677706695399-promote_to_production_2023_01_03.js +49 -0
- package/dist/migrations/1677706695399-promote_to_production_2023_01_03.js.map +1 -0
- package/dist/migrations/1677763068338-task-1032V1.d.ts +6 -0
- package/dist/migrations/1677763068338-task-1032V1.js +51 -0
- package/dist/migrations/1677763068338-task-1032V1.js.map +1 -0
- package/dist/migrations/1677764464274-task-1032V2.d.ts +6 -0
- package/dist/migrations/1677764464274-task-1032V2.js +33 -0
- package/dist/migrations/1677764464274-task-1032V2.js.map +1 -0
- package/dist/repositories/index.d.ts +9 -0
- package/dist/repositories/index.js +23 -2
- package/dist/repositories/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +114 -11
- package/package.json +3 -3
- package/src/entity/Attribute.ts +30 -0
- package/src/entity/Category.ts +28 -2
- package/src/entity/CategoryImages.ts +38 -0
- package/src/entity/Product.entity.ts +9 -0
- package/src/entity/ProductAttribute.ts +27 -0
- package/src/entity/Subcategory.ts +6 -2
- package/src/entity/index.ts +7 -0
- package/src/migrations/1677706695399-promote_to_production_2023_01_03.ts +34 -0
- package/src/migrations/1677763068338-task-1032V1.ts +57 -0
- package/src/migrations/1677764464274-task-1032V2.ts +18 -0
- package/src/repositories/index.ts +13 -0
|
@@ -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
|
|
package/src/entity/index.ts
CHANGED
|
@@ -74,6 +74,10 @@ import CustomVariant from './CustomVariant';
|
|
|
74
74
|
import { CustomProduct } from './CustomProduct';
|
|
75
75
|
import CustomProductImage from './CustomProductImage';
|
|
76
76
|
|
|
77
|
+
import Attribute from './Attribute';
|
|
78
|
+
import ProductAttribute from './ProductAttribute';
|
|
79
|
+
import CategoryImages from './CategoryImages';
|
|
80
|
+
|
|
77
81
|
export {
|
|
78
82
|
CustomVariant,
|
|
79
83
|
CustomProduct,
|
|
@@ -145,4 +149,7 @@ export {
|
|
|
145
149
|
UserChannelApiKey,
|
|
146
150
|
Currency,
|
|
147
151
|
ExchangeRate,
|
|
152
|
+
Attribute,
|
|
153
|
+
ProductAttribute,
|
|
154
|
+
CategoryImages,
|
|
148
155
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {MigrationInterface, QueryRunner} from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class promoteToProduction202301031677706695399 implements MigrationInterface {
|
|
4
|
+
name = 'promoteToProduction202301031677706695399'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE \`custom_product_image\` (\`id\` int NOT NULL AUTO_INCREMENT, \`deleted_at\` datetime(6) NULL, \`url\` varchar(255) NOT NULL, \`width\` int NULL, \`height\` int NULL, \`order\` int NOT NULL, \`product_id\` int NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
8
|
+
await queryRunner.query(`CREATE TABLE \`custom_product\` (\`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, \`title\` varchar(255) NULL, \`description\` text NULL, \`description_two\` text NULL, \`public_price\` decimal(10,2) NULL, \`sku\` varchar(255) NULL, \`barcode\` varchar(255) NULL, \`visible\` tinyint NOT NULL DEFAULT 0, \`product_id\` int NULL, \`user_id\` int NULL, \`price_amount\` decimal(10,2) NULL, \`price_currency_code\` varchar(255) NULL, \`price_base_amount\` decimal(10,2) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
9
|
+
await queryRunner.query(`CREATE TABLE \`custom_variant\` (\`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, \`title\` varchar(255) NOT NULL, \`sku\` varchar(255) NOT NULL, \`barcode\` varchar(255) NULL, \`quantity\` int NOT NULL, \`custom_product_id\` int NULL, \`variant_id\` int NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
10
|
+
await queryRunner.query(`ALTER TABLE \`user_settings\` ADD \`custom_products\` tinyint NOT NULL DEFAULT 0`);
|
|
11
|
+
await queryRunner.query(`ALTER TABLE \`shipping\` ADD \`default\` tinyint NOT NULL DEFAULT 0`);
|
|
12
|
+
await queryRunner.query(`ALTER TABLE \`product\` ADD \`active\` tinyint NOT NULL DEFAULT 0`);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE \`custom_product_image\` ADD CONSTRAINT \`FK_02a813811810b4faf6bac7361a4\` FOREIGN KEY (\`product_id\`) REFERENCES \`custom_product\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
14
|
+
await queryRunner.query(`ALTER TABLE \`custom_product\` ADD CONSTRAINT \`FK_7a615131bff0eb11f4709f77bcf\` FOREIGN KEY (\`product_id\`) REFERENCES \`product\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
15
|
+
await queryRunner.query(`ALTER TABLE \`custom_product\` ADD CONSTRAINT \`FK_f89b6142de14e0db9655247b926\` FOREIGN KEY (\`user_id\`) REFERENCES \`user\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
16
|
+
await queryRunner.query(`ALTER TABLE \`custom_variant\` ADD CONSTRAINT \`FK_c30da998f87bb92036e815ebdf6\` FOREIGN KEY (\`custom_product_id\`) REFERENCES \`custom_product\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
17
|
+
await queryRunner.query(`ALTER TABLE \`custom_variant\` ADD CONSTRAINT \`FK_2266fdf123653773d75afd951da\` FOREIGN KEY (\`variant_id\`) REFERENCES \`variant\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
21
|
+
await queryRunner.query(`ALTER TABLE \`custom_variant\` DROP FOREIGN KEY \`FK_2266fdf123653773d75afd951da\``);
|
|
22
|
+
await queryRunner.query(`ALTER TABLE \`custom_variant\` DROP FOREIGN KEY \`FK_c30da998f87bb92036e815ebdf6\``);
|
|
23
|
+
await queryRunner.query(`ALTER TABLE \`custom_product\` DROP FOREIGN KEY \`FK_f89b6142de14e0db9655247b926\``);
|
|
24
|
+
await queryRunner.query(`ALTER TABLE \`custom_product\` DROP FOREIGN KEY \`FK_7a615131bff0eb11f4709f77bcf\``);
|
|
25
|
+
await queryRunner.query(`ALTER TABLE \`custom_product_image\` DROP FOREIGN KEY \`FK_02a813811810b4faf6bac7361a4\``);
|
|
26
|
+
await queryRunner.query(`ALTER TABLE \`product\` DROP COLUMN \`active\``);
|
|
27
|
+
await queryRunner.query(`ALTER TABLE \`shipping\` DROP COLUMN \`default\``);
|
|
28
|
+
await queryRunner.query(`ALTER TABLE \`user_settings\` DROP COLUMN \`custom_products\``);
|
|
29
|
+
await queryRunner.query(`DROP TABLE \`custom_variant\``);
|
|
30
|
+
await queryRunner.query(`DROP TABLE \`custom_product\``);
|
|
31
|
+
await queryRunner.query(`DROP TABLE \`custom_product_image\``);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -51,6 +51,10 @@ import CustomVariant from '../entity/CustomVariant';
|
|
|
51
51
|
import { CustomProduct } from '../entity/CustomProduct';
|
|
52
52
|
import CustomProductImage from '../entity/CustomProductImage';
|
|
53
53
|
|
|
54
|
+
import Attribute from '../entity/Attribute';
|
|
55
|
+
import ProductAttribute from '../entity/ProductAttribute';
|
|
56
|
+
import CategoryImages from '../entity/CategoryImages';
|
|
57
|
+
|
|
54
58
|
import {
|
|
55
59
|
CartItemRepository,
|
|
56
60
|
CartRepository,
|
|
@@ -68,6 +72,15 @@ import {
|
|
|
68
72
|
|
|
69
73
|
import { Repository, EntityRepository } from 'typeorm';
|
|
70
74
|
|
|
75
|
+
@EntityRepository(CategoryImages)
|
|
76
|
+
export class CategoryImagesRepository extends Repository<CategoryImages> {}
|
|
77
|
+
|
|
78
|
+
@EntityRepository(ProductAttribute)
|
|
79
|
+
export class ProductAttributeRepository extends Repository<ProductAttribute> {}
|
|
80
|
+
|
|
81
|
+
@EntityRepository(Attribute)
|
|
82
|
+
export class AttributeRepository extends Repository<Attribute> {}
|
|
83
|
+
|
|
71
84
|
@EntityRepository(CustomVariant)
|
|
72
85
|
export class CustomVariantRepository extends Repository<CustomVariant> {}
|
|
73
86
|
|