@reachu/database 1.0.92 → 1.0.94
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/ImportedProduct.js +1 -1
- package/dist/entity/ImportedProduct.js.map +1 -1
- package/dist/entity/Variant.d.ts +1 -0
- package/dist/entity/Variant.js +4 -0
- package/dist/entity/Variant.js.map +1 -1
- package/dist/entity/index.d.ts +5 -1
- package/dist/entity/index.js +9 -1
- package/dist/entity/index.js.map +1 -1
- package/dist/entity/modules/discount/Discount.d.ts +16 -0
- package/dist/entity/modules/discount/Discount.js +72 -0
- package/dist/entity/modules/discount/Discount.js.map +1 -0
- package/dist/entity/modules/discount/DiscountCart.d.ts +9 -0
- package/dist/entity/modules/discount/DiscountCart.js +47 -0
- package/dist/entity/modules/discount/DiscountCart.js.map +1 -0
- package/dist/entity/modules/discount/DiscountProduct.d.ts +9 -0
- package/dist/entity/modules/discount/DiscountProduct.js +47 -0
- package/dist/entity/modules/discount/DiscountProduct.js.map +1 -0
- package/dist/entity/modules/discount/DiscountType.d.ts +8 -0
- package/dist/entity/modules/discount/DiscountType.js +41 -0
- package/dist/entity/modules/discount/DiscountType.js.map +1 -0
- package/dist/migrations/1688921300692-migration-pre-develop-user-channel-exported-product.d.ts +6 -0
- package/dist/migrations/1688921300692-migration-pre-develop-user-channel-exported-product.js +31 -0
- package/dist/migrations/1688921300692-migration-pre-develop-user-channel-exported-product.js.map +1 -0
- package/dist/migrations/1688925248106-migration-pre-develop-user-channel-exported-product_v1.d.ts +6 -0
- package/dist/migrations/1688925248106-migration-pre-develop-user-channel-exported-product_v1.js +31 -0
- package/dist/migrations/1688925248106-migration-pre-develop-user-channel-exported-product_v1.js.map +1 -0
- package/dist/migrations/1689005718747-add-active-colum-in-variant.d.ts +6 -0
- package/dist/migrations/1689005718747-add-active-colum-in-variant.js +47 -0
- package/dist/migrations/1689005718747-add-active-colum-in-variant.js.map +1 -0
- package/dist/migrations/1689020331011-add-discount.d.ts +6 -0
- package/dist/migrations/1689020331011-add-discount.js +45 -0
- package/dist/migrations/1689020331011-add-discount.js.map +1 -0
- package/dist/repositories/discount/index.d.ts +13 -0
- package/dist/repositories/discount/index.js +42 -0
- package/dist/repositories/discount/index.js.map +1 -0
- package/dist/repositories/index.d.ts +2 -0
- package/dist/repositories/index.js +6 -1
- package/dist/repositories/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +153 -7
- package/package.json +3 -3
- package/src/entity/ImportedProduct.ts +1 -1
- package/src/entity/Variant.ts +3 -0
- package/src/entity/index.ts +10 -0
- package/src/entity/modules/discount/Discount.ts +52 -0
- package/src/entity/modules/discount/DiscountCart.ts +25 -0
- package/src/entity/modules/discount/DiscountProduct.ts +25 -0
- package/src/entity/modules/discount/DiscountType.ts +26 -0
- package/src/migrations/1688921300692-migration-pre-develop-user-channel-exported-product.ts +16 -0
- package/src/migrations/1688925248106-migration-pre-develop-user-channel-exported-product_v1.ts +16 -0
- package/src/migrations/1689005718747-add-active-colum-in-variant.ts +32 -0
- package/src/migrations/1689020331011-add-discount.ts +30 -0
- package/src/repositories/discount/index.ts +18 -0
- package/src/repositories/index.ts +14 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Entity, PrimaryGeneratedColumn, DeleteDateColumn, JoinColumn, ManyToOne } from 'typeorm';
|
|
2
|
+
import AuditedModel from '../../AuditedModel';
|
|
3
|
+
import Discount from './Discount';
|
|
4
|
+
import Cart from '../../modules/shopcart/Cart';
|
|
5
|
+
|
|
6
|
+
@Entity()
|
|
7
|
+
export default class DiscountCart extends AuditedModel {
|
|
8
|
+
@PrimaryGeneratedColumn()
|
|
9
|
+
id: number;
|
|
10
|
+
|
|
11
|
+
@DeleteDateColumn()
|
|
12
|
+
deletedAt: Date;
|
|
13
|
+
|
|
14
|
+
@ManyToOne(() => Discount, (discount: Discount) => discount.id, {
|
|
15
|
+
nullable: false,
|
|
16
|
+
})
|
|
17
|
+
@JoinColumn()
|
|
18
|
+
discount: Discount;
|
|
19
|
+
|
|
20
|
+
@ManyToOne(() => Cart, (cart: Cart) => cart.id, {
|
|
21
|
+
nullable: false,
|
|
22
|
+
})
|
|
23
|
+
@JoinColumn()
|
|
24
|
+
cart: Cart;
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Entity, PrimaryGeneratedColumn, DeleteDateColumn, JoinColumn, ManyToOne } from 'typeorm';
|
|
2
|
+
import AuditedModel from '../../AuditedModel';
|
|
3
|
+
import Discount from './Discount';
|
|
4
|
+
import { Product } from '../../Product.entity';
|
|
5
|
+
|
|
6
|
+
@Entity()
|
|
7
|
+
export default class DiscountProduct extends AuditedModel {
|
|
8
|
+
@PrimaryGeneratedColumn()
|
|
9
|
+
id: number;
|
|
10
|
+
|
|
11
|
+
@DeleteDateColumn()
|
|
12
|
+
deletedAt: Date;
|
|
13
|
+
|
|
14
|
+
@ManyToOne(() => Product, (product: Product) => product.id, {
|
|
15
|
+
nullable: false,
|
|
16
|
+
})
|
|
17
|
+
@JoinColumn()
|
|
18
|
+
product: Product;
|
|
19
|
+
|
|
20
|
+
@ManyToOne(() => Discount, (discount: Discount) => discount.id, {
|
|
21
|
+
nullable: false,
|
|
22
|
+
})
|
|
23
|
+
@JoinColumn()
|
|
24
|
+
discount: Discount;
|
|
25
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
PrimaryGeneratedColumn,
|
|
4
|
+
DeleteDateColumn,
|
|
5
|
+
Column,
|
|
6
|
+
OneToMany,
|
|
7
|
+
JoinColumn,
|
|
8
|
+
} from 'typeorm';
|
|
9
|
+
import AuditedModel from '../../AuditedModel';
|
|
10
|
+
import Discount from './Discount';
|
|
11
|
+
|
|
12
|
+
@Entity()
|
|
13
|
+
export default class DiscountType extends AuditedModel {
|
|
14
|
+
@PrimaryGeneratedColumn()
|
|
15
|
+
id: number;
|
|
16
|
+
|
|
17
|
+
@DeleteDateColumn()
|
|
18
|
+
deletedAt: Date;
|
|
19
|
+
|
|
20
|
+
@Column('varchar', { nullable: false })
|
|
21
|
+
type: string;
|
|
22
|
+
|
|
23
|
+
@OneToMany(() => Discount, (discount: Discount) => discount.discountType)
|
|
24
|
+
@JoinColumn()
|
|
25
|
+
discount: Discount[];
|
|
26
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {MigrationInterface, QueryRunner} from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class migrationPreDevelopUserChannelExportedProduct1688921300692 implements MigrationInterface {
|
|
4
|
+
name = 'migrationPreDevelopUserChannelExportedProduct1688921300692'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` ADD \`channel_user_id\` int NULL`);
|
|
8
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` ADD CONSTRAINT \`FK_f8bdfc8b3e1fdf9e96a351d73e2\` FOREIGN KEY (\`channel_user_id\`) REFERENCES \`user\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
12
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` DROP FOREIGN KEY \`FK_f8bdfc8b3e1fdf9e96a351d73e2\``);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` DROP COLUMN \`channel_user_id\``);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
package/src/migrations/1688925248106-migration-pre-develop-user-channel-exported-product_v1.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {MigrationInterface, QueryRunner} from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class migrationPreDevelopUserChannelExportedProductV11688925248106 implements MigrationInterface {
|
|
4
|
+
name = 'migrationPreDevelopUserChannelExportedProductV11688925248106'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` DROP FOREIGN KEY \`FK_f8bdfc8b3e1fdf9e96a351d73e2\``);
|
|
8
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` ADD CONSTRAINT \`FK_f8bdfc8b3e1fdf9e96a351d73e2\` FOREIGN KEY (\`channel_user_id\`) REFERENCES \`channel_user\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
12
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` DROP FOREIGN KEY \`FK_f8bdfc8b3e1fdf9e96a351d73e2\``);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` ADD CONSTRAINT \`FK_f8bdfc8b3e1fdf9e96a351d73e2\` FOREIGN KEY (\`channel_user_id\`) REFERENCES \`user\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {MigrationInterface, QueryRunner} from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class addActiveColumInVariant1689005718747 implements MigrationInterface {
|
|
4
|
+
name = 'addActiveColumInVariant1689005718747'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE \`user_channel_api_key\` DROP FOREIGN KEY \`FK_adc2206f21efb67f9f6425a4ce8\``);
|
|
8
|
+
await queryRunner.query(`DROP INDEX \`IDX_db41f18c3701a209c734457fa3\` ON \`shopify_connection\``);
|
|
9
|
+
await queryRunner.query(`ALTER TABLE \`user_channel_api_key\` DROP COLUMN \`channel_user_id\``);
|
|
10
|
+
await queryRunner.query(`ALTER TABLE \`variant\` ADD \`active\` tinyint NOT NULL DEFAULT 1`);
|
|
11
|
+
await queryRunner.query(`ALTER TABLE \`channel_user\` ADD \`shopify_connection_id\` int NULL`);
|
|
12
|
+
await queryRunner.query(`ALTER TABLE \`channel_user\` ADD \`user_channel_api_key_id\` int NULL`);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` ADD \`channel_user_id\` int NULL`);
|
|
14
|
+
await queryRunner.query(`ALTER TABLE \`channel_user\` ADD CONSTRAINT \`FK_687a267ae83f576c002baf0198a\` FOREIGN KEY (\`shopify_connection_id\`) REFERENCES \`shopify_connection\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
15
|
+
await queryRunner.query(`ALTER TABLE \`channel_user\` ADD CONSTRAINT \`FK_83f345b5912388def4fa4253040\` FOREIGN KEY (\`user_channel_api_key_id\`) REFERENCES \`user_channel_api_key\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
16
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` ADD CONSTRAINT \`FK_f8bdfc8b3e1fdf9e96a351d73e2\` FOREIGN KEY (\`channel_user_id\`) REFERENCES \`channel_user\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
20
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` DROP FOREIGN KEY \`FK_f8bdfc8b3e1fdf9e96a351d73e2\``);
|
|
21
|
+
await queryRunner.query(`ALTER TABLE \`channel_user\` DROP FOREIGN KEY \`FK_83f345b5912388def4fa4253040\``);
|
|
22
|
+
await queryRunner.query(`ALTER TABLE \`channel_user\` DROP FOREIGN KEY \`FK_687a267ae83f576c002baf0198a\``);
|
|
23
|
+
await queryRunner.query(`ALTER TABLE \`imported_product\` DROP COLUMN \`channel_user_id\``);
|
|
24
|
+
await queryRunner.query(`ALTER TABLE \`channel_user\` DROP COLUMN \`user_channel_api_key_id\``);
|
|
25
|
+
await queryRunner.query(`ALTER TABLE \`channel_user\` DROP COLUMN \`shopify_connection_id\``);
|
|
26
|
+
await queryRunner.query(`ALTER TABLE \`variant\` DROP COLUMN \`active\``);
|
|
27
|
+
await queryRunner.query(`ALTER TABLE \`user_channel_api_key\` ADD \`channel_user_id\` int NULL`);
|
|
28
|
+
await queryRunner.query(`CREATE UNIQUE INDEX \`IDX_db41f18c3701a209c734457fa3\` ON \`shopify_connection\` (\`reseller_id\`, \`deleted_at\`)`);
|
|
29
|
+
await queryRunner.query(`ALTER TABLE \`user_channel_api_key\` ADD CONSTRAINT \`FK_adc2206f21efb67f9f6425a4ce8\` FOREIGN KEY (\`channel_user_id\`) REFERENCES \`channel_user\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {MigrationInterface, QueryRunner} from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class addDiscount1689020331011 implements MigrationInterface {
|
|
4
|
+
name = 'addDiscount1689020331011'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE \`discount_type\` (\`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, \`type\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
8
|
+
await queryRunner.query(`CREATE TABLE \`discount_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, \`product_id\` int NOT NULL, \`discount_id\` int NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
9
|
+
await queryRunner.query(`CREATE TABLE \`discount_cart\` (\`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, \`discount_id\` int NOT NULL, \`cart_id\` varchar(36) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
10
|
+
await queryRunner.query(`CREATE TABLE \`discount\` (\`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, \`discount_count\` int NULL, \`code\` varchar(255) NOT NULL, \`percentage\` int NOT NULL, \`start_date\` datetime NOT NULL, \`end_date\` datetime NOT NULL, \`discount_type_id\` int NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
11
|
+
await queryRunner.query(`ALTER TABLE \`discount_product\` ADD CONSTRAINT \`FK_6939b3f91b1db4d133d20c33e3b\` FOREIGN KEY (\`product_id\`) REFERENCES \`product\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
12
|
+
await queryRunner.query(`ALTER TABLE \`discount_product\` ADD CONSTRAINT \`FK_6cfb1683e023b96a42f7e72edd6\` FOREIGN KEY (\`discount_id\`) REFERENCES \`discount\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE \`discount_cart\` ADD CONSTRAINT \`FK_ff034b5de6a90766ce209ae92a4\` FOREIGN KEY (\`discount_id\`) REFERENCES \`discount\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
14
|
+
await queryRunner.query(`ALTER TABLE \`discount_cart\` ADD CONSTRAINT \`FK_42951860fa261b863933523298e\` FOREIGN KEY (\`cart_id\`) REFERENCES \`cart\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
15
|
+
await queryRunner.query(`ALTER TABLE \`discount\` ADD CONSTRAINT \`FK_40b4ec0b1661fe175e00646f507\` FOREIGN KEY (\`discount_type_id\`) REFERENCES \`discount_type\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
19
|
+
await queryRunner.query(`ALTER TABLE \`discount\` DROP FOREIGN KEY \`FK_40b4ec0b1661fe175e00646f507\``);
|
|
20
|
+
await queryRunner.query(`ALTER TABLE \`discount_cart\` DROP FOREIGN KEY \`FK_42951860fa261b863933523298e\``);
|
|
21
|
+
await queryRunner.query(`ALTER TABLE \`discount_cart\` DROP FOREIGN KEY \`FK_ff034b5de6a90766ce209ae92a4\``);
|
|
22
|
+
await queryRunner.query(`ALTER TABLE \`discount_product\` DROP FOREIGN KEY \`FK_6cfb1683e023b96a42f7e72edd6\``);
|
|
23
|
+
await queryRunner.query(`ALTER TABLE \`discount_product\` DROP FOREIGN KEY \`FK_6939b3f91b1db4d133d20c33e3b\``);
|
|
24
|
+
await queryRunner.query(`DROP TABLE \`discount\``);
|
|
25
|
+
await queryRunner.query(`DROP TABLE \`discount_cart\``);
|
|
26
|
+
await queryRunner.query(`DROP TABLE \`discount_product\``);
|
|
27
|
+
await queryRunner.query(`DROP TABLE \`discount_type\``);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Repository, EntityRepository } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
import Discount from '../../entity/modules/discount/Discount';
|
|
4
|
+
import DiscountCart from '../../entity/modules/discount/DiscountCart';
|
|
5
|
+
import DiscountProduct from '../../entity/modules/discount/DiscountProduct';
|
|
6
|
+
import DiscountType from '../../entity/modules/discount/DiscountType';
|
|
7
|
+
|
|
8
|
+
@EntityRepository(Discount)
|
|
9
|
+
export class DiscountRepository extends Repository<Discount> {}
|
|
10
|
+
|
|
11
|
+
@EntityRepository(DiscountCart)
|
|
12
|
+
export class DiscountCartRepository extends Repository<DiscountCart> {}
|
|
13
|
+
|
|
14
|
+
@EntityRepository(DiscountProduct)
|
|
15
|
+
export class DiscountProductRepository extends Repository<DiscountProduct> {}
|
|
16
|
+
|
|
17
|
+
@EntityRepository(DiscountType)
|
|
18
|
+
export class DiscountTypeRepository extends Repository<DiscountType> {}
|
|
@@ -94,6 +94,13 @@ import {
|
|
|
94
94
|
UserTemplateEcommerceRepository,
|
|
95
95
|
} from './templates';
|
|
96
96
|
|
|
97
|
+
import {
|
|
98
|
+
DiscountRepository,
|
|
99
|
+
DiscountCartRepository,
|
|
100
|
+
DiscountProductRepository,
|
|
101
|
+
DiscountTypeRepository,
|
|
102
|
+
} from './discount';
|
|
103
|
+
|
|
97
104
|
import { PlanRepository, SubscriptionRepository, UserCountPlanRepository } from './subscriptions';
|
|
98
105
|
|
|
99
106
|
import { Repository, EntityRepository } from 'typeorm';
|
|
@@ -299,6 +306,13 @@ export {
|
|
|
299
306
|
UserTemplateEcommerceRepository,
|
|
300
307
|
};
|
|
301
308
|
|
|
309
|
+
export {
|
|
310
|
+
DiscountRepository,
|
|
311
|
+
DiscountCartRepository,
|
|
312
|
+
DiscountProductRepository,
|
|
313
|
+
DiscountTypeRepository,
|
|
314
|
+
};
|
|
315
|
+
|
|
302
316
|
export { ProductShippingRepository, ShippingCountryRepository, ShippingRepository };
|
|
303
317
|
|
|
304
318
|
export { PlanRepository, SubscriptionRepository, UserCountPlanRepository };
|