fix: Use integer for variant and category ranks (#7572)
This commit is contained in:
@@ -74,13 +74,13 @@
|
||||
},
|
||||
"rank": {
|
||||
"name": "rank",
|
||||
"type": "numeric",
|
||||
"type": "integer",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"default": "0",
|
||||
"mappedType": "decimal"
|
||||
"mappedType": "integer"
|
||||
},
|
||||
"parent_category_id": {
|
||||
"name": "parent_category_id",
|
||||
@@ -1378,13 +1378,13 @@
|
||||
},
|
||||
"variant_rank": {
|
||||
"name": "variant_rank",
|
||||
"type": "numeric",
|
||||
"type": "integer",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": true,
|
||||
"default": "0",
|
||||
"mappedType": "decimal"
|
||||
"mappedType": "integer"
|
||||
},
|
||||
"product_id": {
|
||||
"name": "product_id",
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Migration } from "@mikro-orm/migrations"
|
||||
|
||||
export class Migration20240601111544 extends Migration {
|
||||
async up(): Promise<void> {
|
||||
this.addSql(
|
||||
'alter table if exists "product_category" alter column "rank" type integer using ("rank"::integer);'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'alter table if exists "product_variant" alter column "variant_rank" type integer using ("variant_rank"::integer);'
|
||||
)
|
||||
}
|
||||
|
||||
async down(): Promise<void> {
|
||||
this.addSql(
|
||||
'alter table if exists "product_category" alter column "rank" type numeric using ("rank"::numeric);'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'alter table if exists "product_variant" alter column "variant_rank" type numeric using ("variant_rank"::numeric);'
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,11 @@ class ProductCategory {
|
||||
@Property({ columnType: "boolean", default: false })
|
||||
is_internal?: boolean
|
||||
|
||||
@Property({ columnType: "numeric", nullable: false, default: 0 })
|
||||
@Property({
|
||||
columnType: "integer",
|
||||
nullable: false,
|
||||
default: 0,
|
||||
})
|
||||
rank?: number
|
||||
|
||||
@ManyToOne(() => ProductCategory, {
|
||||
|
||||
@@ -130,12 +130,10 @@ class ProductVariant {
|
||||
@Property({ columnType: "jsonb", nullable: true })
|
||||
metadata?: Record<string, unknown> | null
|
||||
|
||||
// TODO: replace with BigNumber, or in this case a normal int should work
|
||||
@Property({
|
||||
columnType: "numeric",
|
||||
columnType: "integer",
|
||||
nullable: true,
|
||||
default: 0,
|
||||
serializer: optionalNumericSerializer,
|
||||
})
|
||||
variant_rank?: number | null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user