chore: create indexes on foreign keys (#164)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
@@ -19,6 +20,7 @@ export class Address {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
customer_id: string
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
Index,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
@@ -42,6 +43,7 @@ export class Cart {
|
||||
@Column({ nullable: true })
|
||||
email: string
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
billing_address_id: string
|
||||
|
||||
@@ -51,6 +53,7 @@ export class Cart {
|
||||
@JoinColumn({ name: "billing_address_id" })
|
||||
billing_address: Address
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
shipping_address_id: string
|
||||
|
||||
@@ -67,6 +70,7 @@ export class Cart {
|
||||
)
|
||||
items: LineItem[]
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
region_id: string
|
||||
|
||||
@@ -102,6 +106,7 @@ export class Cart {
|
||||
})
|
||||
gift_cards: GiftCard
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
customer_id: string
|
||||
|
||||
@@ -118,6 +123,7 @@ export class Cart {
|
||||
)
|
||||
payment_sessions: PaymentSession[]
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
payment_id: string
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
@@ -18,6 +19,7 @@ export class ClaimImage {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
claim_item_id: string
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ export class ClaimOrder {
|
||||
@Column({ type: "enum", enum: ClaimType })
|
||||
type: ClaimType
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
order_id: string
|
||||
|
||||
@@ -96,6 +97,7 @@ export class ClaimOrder {
|
||||
)
|
||||
return_order: Return
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
shipping_address_id: string
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ export class Country {
|
||||
@Column()
|
||||
display_name: string
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
region_id: string
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ export class Customer {
|
||||
@Column({ nullable: true })
|
||||
last_name: string
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
billing_address_id: string
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ export class Discount {
|
||||
@Column()
|
||||
is_dynamic: boolean
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
rule_id: string
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
RelationId,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Index,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
@@ -27,6 +28,7 @@ export class Fulfillment {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
claim_order_id: string
|
||||
|
||||
@@ -37,6 +39,7 @@ export class Fulfillment {
|
||||
@JoinColumn({ name: "claim_order_id" })
|
||||
claim_order: ClaimOrder
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
swap_id: string
|
||||
|
||||
@@ -47,6 +50,7 @@ export class Fulfillment {
|
||||
@JoinColumn({ name: "swap_id" })
|
||||
swap: Swap
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
order_id: string
|
||||
|
||||
@@ -57,6 +61,7 @@ export class Fulfillment {
|
||||
@JoinColumn({ name: "order_id" })
|
||||
order: Order
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
provider_id: string
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
Index,
|
||||
CreateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
@@ -26,6 +27,7 @@ export class GiftCardTransaction {
|
||||
@JoinColumn({ name: "gift_card_id" })
|
||||
gift_card: GiftCard
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
order_id: string
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ export class GiftCard {
|
||||
@Column("int")
|
||||
balance: number
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
region_id: string
|
||||
|
||||
@@ -38,6 +39,7 @@ export class GiftCard {
|
||||
@JoinColumn({ name: "region_id" })
|
||||
region: Region
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
order_id: string
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Index,
|
||||
RelationId,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
@@ -38,6 +39,7 @@ export class MoneyAmount {
|
||||
@Column({ type: "int", nullable: true, default: null })
|
||||
sale_amount: number
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
variant_id: string
|
||||
|
||||
@@ -45,6 +47,7 @@ export class MoneyAmount {
|
||||
@JoinColumn({ name: "variant_id" })
|
||||
variant: ProductVariant
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
region_id: string
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
Entity,
|
||||
Generated,
|
||||
BeforeInsert,
|
||||
Index,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
@@ -76,10 +77,12 @@ export class Order {
|
||||
@Column({ type: "enum", enum: PaymentStatus, default: "not_paid" })
|
||||
payment_status: PaymentStatus
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
@Generated("increment")
|
||||
display_id: number
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
cart_id: string
|
||||
|
||||
@@ -87,6 +90,7 @@ export class Order {
|
||||
@JoinColumn({ name: "cart_id" })
|
||||
cart: Cart
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
customer_id: string
|
||||
|
||||
@@ -97,6 +101,7 @@ export class Order {
|
||||
@Column()
|
||||
email: string
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
billing_address_id: string
|
||||
|
||||
@@ -104,6 +109,7 @@ export class Order {
|
||||
@JoinColumn({ name: "billing_address_id" })
|
||||
billing_address: Address
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
shipping_address_id: string
|
||||
|
||||
@@ -111,6 +117,7 @@ export class Order {
|
||||
@JoinColumn({ name: "shipping_address_id" })
|
||||
shipping_address: Address
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
region_id: string
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
Entity,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
@@ -9,7 +10,7 @@ import {
|
||||
JoinColumn,
|
||||
Unique,
|
||||
} from "typeorm"
|
||||
import {ulid } from "ulid"
|
||||
import { ulid } from "ulid"
|
||||
import { Cart } from "./cart"
|
||||
|
||||
export enum PaymentSessionStatus {
|
||||
@@ -26,6 +27,7 @@ export class PaymentSession {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
cart_id: string
|
||||
|
||||
@@ -36,6 +38,7 @@ export class PaymentSession {
|
||||
@JoinColumn({ name: "cart_id" })
|
||||
cart: Cart
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
provider_id: string
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
@@ -21,6 +22,7 @@ export class Payment {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
swap_id: string
|
||||
|
||||
@@ -28,6 +30,7 @@ export class Payment {
|
||||
@JoinColumn({ name: "swap_id" })
|
||||
swap: Swap
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
cart_id: string
|
||||
|
||||
@@ -35,6 +38,7 @@ export class Payment {
|
||||
@JoinColumn({ name: "cart_id" })
|
||||
cart: Cart
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
order_id: string
|
||||
|
||||
@@ -58,6 +62,7 @@ export class Payment {
|
||||
@Column({ type: "int", default: 0 })
|
||||
amount_refunded: number
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
provider_id: string
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ export class ProductOptionValue {
|
||||
@JoinColumn({ name: "option_id" })
|
||||
option: ProductOption
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
variant_id: string
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ export class ProductVariant {
|
||||
@Column()
|
||||
title: string
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
product_id: string
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ export class Product {
|
||||
)
|
||||
variants: ProductVariant[]
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
profile_id: string
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Index,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
@@ -28,6 +29,7 @@ export class Refund {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
order_id: string
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
RelationId,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
@@ -43,6 +44,7 @@ export class Return {
|
||||
)
|
||||
items: ReturnItem[]
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
swap_id: string
|
||||
|
||||
@@ -53,6 +55,7 @@ export class Return {
|
||||
@JoinColumn({ name: "swap_id" })
|
||||
swap: Swap
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
claim_order_id: string
|
||||
|
||||
@@ -63,6 +66,7 @@ export class Return {
|
||||
@JoinColumn({ name: "claim_order_id" })
|
||||
claim_order: ClaimOrder
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
order_id: string
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Index,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
@@ -28,6 +29,7 @@ export class ShippingOptionRequirement {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
shipping_option_id: string
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
Entity,
|
||||
Check,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
@@ -36,6 +37,7 @@ export class ShippingOption {
|
||||
@Column()
|
||||
name: string
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
region_id: string
|
||||
|
||||
@@ -43,6 +45,7 @@ export class ShippingOption {
|
||||
@JoinColumn({ name: "region_id" })
|
||||
region: Region
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
profile_id: string
|
||||
|
||||
@@ -50,6 +53,7 @@ export class ShippingOption {
|
||||
@JoinColumn({ name: "profile_id" })
|
||||
profile: ShippingProfile
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
provider_id: string
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
@@ -54,6 +55,7 @@ export class Swap {
|
||||
@Column({ type: "enum", enum: PaymentStatus })
|
||||
payment_status: PaymentStatus
|
||||
|
||||
@Index()
|
||||
@Column({ type: "string" })
|
||||
order_id: string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user