update review entity
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-15 12:07:58 +03:30
parent a05643daf5
commit 204b4f2007
7 changed files with 266 additions and 296 deletions
+222 -245
View File
@@ -4666,6 +4666,228 @@
"foreignKeys": {},
"nativeEnums": {}
},
{
"columns": {
"id": {
"name": "id",
"type": "char(26)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 26,
"mappedType": "character"
},
"created_at": {
"name": "created_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 6,
"default": "now()",
"mappedType": "datetime"
},
"updated_at": {
"name": "updated_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 6,
"default": "now()",
"mappedType": "datetime"
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"length": 6,
"mappedType": "datetime"
},
"is_buyer": {
"name": "is_buyer",
"type": "boolean",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"default": "false",
"mappedType": "boolean"
},
"food_id": {
"name": "food_id",
"type": "char(26)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 26,
"mappedType": "character"
},
"user_id": {
"name": "user_id",
"type": "char(26)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 26,
"mappedType": "character"
},
"comment": {
"name": "comment",
"type": "text",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "text"
},
"rating": {
"name": "rating",
"type": "int",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"default": "0",
"mappedType": "integer"
},
"positive_points": {
"name": "positive_points",
"type": "jsonb",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "json"
},
"negative_points": {
"name": "negative_points",
"type": "jsonb",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "json"
},
"status": {
"name": "status",
"type": "text",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"default": "'pending'",
"enumItems": [
"pending",
"rejected",
"approved"
],
"mappedType": "enum"
}
},
"name": "reviews",
"schema": "public",
"indexes": [
{
"keyName": "reviews_created_at_index",
"columnNames": [
"created_at"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "reviews_deleted_at_index",
"columnNames": [
"deleted_at"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "reviews_user_id_index",
"columnNames": [
"user_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "reviews_food_id_status_index",
"columnNames": [
"food_id",
"status"
],
"composite": true,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "reviews_food_id_user_id_unique",
"columnNames": [
"food_id",
"user_id"
],
"composite": true,
"constraint": true,
"primary": false,
"unique": true
},
{
"keyName": "reviews_pkey",
"columnNames": [
"id"
],
"composite": false,
"constraint": true,
"primary": true,
"unique": true
}
],
"checks": [],
"foreignKeys": {
"reviews_food_id_foreign": {
"constraintName": "reviews_food_id_foreign",
"columnNames": [
"food_id"
],
"localTableName": "public.reviews",
"referencedColumnNames": [
"id"
],
"referencedTableName": "public.foods",
"updateRule": "cascade"
},
"reviews_user_id_foreign": {
"constraintName": "reviews_user_id_foreign",
"columnNames": [
"user_id"
],
"localTableName": "public.reviews",
"referencedColumnNames": [
"id"
],
"referencedTableName": "public.users",
"updateRule": "cascade"
}
},
"nativeEnums": {}
},
{
"columns": {
"id": {
@@ -5501,251 +5723,6 @@
},
"nativeEnums": {}
},
{
"columns": {
"id": {
"name": "id",
"type": "char(26)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 26,
"mappedType": "character"
},
"created_at": {
"name": "created_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 6,
"default": "now()",
"mappedType": "datetime"
},
"updated_at": {
"name": "updated_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 6,
"default": "now()",
"mappedType": "datetime"
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"length": 6,
"mappedType": "datetime"
},
"order_id": {
"name": "order_id",
"type": "char(26)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 26,
"mappedType": "character"
},
"food_id": {
"name": "food_id",
"type": "char(26)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 26,
"mappedType": "character"
},
"user_id": {
"name": "user_id",
"type": "char(26)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 26,
"mappedType": "character"
},
"comment": {
"name": "comment",
"type": "text",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "text"
},
"rating": {
"name": "rating",
"type": "int",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"default": "0",
"mappedType": "integer"
},
"positive_points": {
"name": "positive_points",
"type": "jsonb",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "json"
},
"negative_points": {
"name": "negative_points",
"type": "jsonb",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "json"
},
"status": {
"name": "status",
"type": "text",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"default": "'pending'",
"enumItems": [
"pending",
"rejected",
"approved"
],
"mappedType": "enum"
}
},
"name": "reviews",
"schema": "public",
"indexes": [
{
"keyName": "reviews_created_at_index",
"columnNames": [
"created_at"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "reviews_deleted_at_index",
"columnNames": [
"deleted_at"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "reviews_order_id_index",
"columnNames": [
"order_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "reviews_user_id_index",
"columnNames": [
"user_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "reviews_food_id_status_index",
"columnNames": [
"food_id",
"status"
],
"composite": true,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "reviews_order_id_food_id_user_id_unique",
"columnNames": [
"order_id",
"food_id",
"user_id"
],
"composite": true,
"constraint": true,
"primary": false,
"unique": true
},
{
"keyName": "reviews_pkey",
"columnNames": [
"id"
],
"composite": false,
"constraint": true,
"primary": true,
"unique": true
}
],
"checks": [],
"foreignKeys": {
"reviews_order_id_foreign": {
"constraintName": "reviews_order_id_foreign",
"columnNames": [
"order_id"
],
"localTableName": "public.reviews",
"referencedColumnNames": [
"id"
],
"referencedTableName": "public.orders",
"updateRule": "cascade"
},
"reviews_food_id_foreign": {
"constraintName": "reviews_food_id_foreign",
"columnNames": [
"food_id"
],
"localTableName": "public.reviews",
"referencedColumnNames": [
"id"
],
"referencedTableName": "public.foods",
"updateRule": "cascade"
},
"reviews_user_id_foreign": {
"constraintName": "reviews_user_id_foreign",
"columnNames": [
"user_id"
],
"localTableName": "public.reviews",
"referencedColumnNames": [
"id"
],
"referencedTableName": "public.users",
"updateRule": "cascade"
}
},
"nativeEnums": {}
},
{
"columns": {
"id": {
@@ -0,0 +1,24 @@
import { Migration } from '@mikro-orm/migrations';
export class Migration20260715083002_task extends Migration {
override async up(): Promise<void> {
this.addSql(`alter table "reviews" drop constraint "reviews_order_id_foreign";`);
this.addSql(`drop index "reviews_order_id_index";`);
this.addSql(`alter table "reviews" drop constraint "reviews_order_id_food_id_user_id_unique";`);
this.addSql(`alter table "reviews" add column "is_buyer" boolean not null default false;`);
this.addSql(`alter table "reviews" add constraint "reviews_food_id_user_id_unique" unique ("food_id", "user_id");`);
}
override async down(): Promise<void> {
this.addSql(`alter table "reviews" drop constraint "reviews_food_id_user_id_unique";`);
this.addSql(`alter table "reviews" add column "order_id" char(26) not null;`);
this.addSql(`alter table "reviews" add constraint "reviews_order_id_foreign" foreign key ("order_id") references "orders" ("id") on update cascade;`);
this.addSql(`create index "reviews_order_id_index" on "reviews" ("order_id");`);
this.addSql(`alter table "reviews" add constraint "reviews_order_id_food_id_user_id_unique" unique ("order_id", "food_id", "user_id");`);
}
}