diff --git a/webapp/src/pages/dashboard/order/[id]/index.tsx b/webapp/src/pages/dashboard/order/[id]/index.tsx index ca915a2f..73283ebc 100644 --- a/webapp/src/pages/dashboard/order/[id]/index.tsx +++ b/webapp/src/pages/dashboard/order/[id]/index.tsx @@ -76,6 +76,9 @@ export default function OrderObizPage() { const { data: order } = resultOrder || {}; + const { mutateAsync: mutateCreateSignal } = + api.order.createSignal.useMutation({}); + const amount = useMemo(() => { return formatter2Digits.format( order?.articles?.reduce((acc, curr) => { @@ -126,6 +129,9 @@ export default function OrderObizPage() { }; const signalIssueWithOrder = () => { + mutateCreateSignal({ + id: order.id, + }); onOpenModalSignalIssue(); }; diff --git a/webapp/src/payload/collections/OrderSignal.ts b/webapp/src/payload/collections/OrderSignal.ts new file mode 100644 index 00000000..48255875 --- /dev/null +++ b/webapp/src/payload/collections/OrderSignal.ts @@ -0,0 +1,26 @@ +import { type CollectionConfig } from "payload/types"; +import { isAdmin } from "../access/isAdmin"; + +export const OrderSignals: CollectionConfig = { + slug: "ordersignals", + labels: { + singular: "Signalement", + plural: "Signalements", + }, + access: { + read: isAdmin, + create: isAdmin, + update: isAdmin, + delete: isAdmin, + }, + fields: [ + { + name: "order", + type: "relationship", + label: "Signalement", + relationTo: "orders", + required: true, + unique: true, + }, + ], +}; diff --git a/webapp/src/payload/migrations/20241107_154204.json b/webapp/src/payload/migrations/20241107_154204.json new file mode 100644 index 00000000..2ed02316 --- /dev/null +++ b/webapp/src/payload/migrations/20241107_154204.json @@ -0,0 +1,4315 @@ +{ + "id": "78eaa42a-8674-415f-b827-f4511fc6ee6e", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "5", + "dialect": "pg", + "tables": { + "admins": { + "name": "admins", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "email": { + "name": "email", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "reset_password_token": { + "name": "reset_password_token", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "reset_password_expiration": { + "name": "reset_password_expiration", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "salt": { + "name": "salt", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "hash": { + "name": "hash", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "login_attempts": { + "name": "login_attempts", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "lock_until": { + "name": "lock_until", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "admins_created_at_idx": { + "name": "admins_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + }, + "admins_email_idx": { + "name": "admins_email_idx", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "phone_number": { + "name": "phone_number", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "civility": { + "name": "civility", + "type": "enum_users_civility", + "primaryKey": false, + "notNull": false + }, + "birth_date": { + "name": "birth_date", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "last_name": { + "name": "last_name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "address": { + "name": "address", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "user_email": { + "name": "user_email", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "cejFrom": { + "name": "cejFrom", + "type": "enum_users_cej_from", + "primaryKey": false, + "notNull": false + }, + "timeAtCEJ": { + "name": "timeAtCEJ", + "type": "enum_users_time_at_c_e_j", + "primaryKey": false, + "notNull": false + }, + "hasAJobIdea": { + "name": "hasAJobIdea", + "type": "enum_users_has_a_job_idea", + "primaryKey": false, + "notNull": false + }, + "project_title": { + "name": "project_title", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "project_description": { + "name": "project_description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "status_image": { + "name": "status_image", + "type": "enum_users_status_image", + "primaryKey": false, + "notNull": false + }, + "notification_status": { + "name": "notification_status", + "type": "enum_users_notification_status", + "primaryKey": false, + "notNull": false + }, + "notification_subscription": { + "name": "notification_subscription", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "otp_request_token": { + "name": "otp_request_token", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "cej_id": { + "name": "cej_id", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "email": { + "name": "email", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "reset_password_token": { + "name": "reset_password_token", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "reset_password_expiration": { + "name": "reset_password_expiration", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "salt": { + "name": "salt", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "hash": { + "name": "hash", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "login_attempts": { + "name": "login_attempts", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "lock_until": { + "name": "lock_until", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_phone_number_idx": { + "name": "users_phone_number_idx", + "columns": [ + "phone_number" + ], + "isUnique": true + }, + "users_cej_id_idx": { + "name": "users_cej_id_idx", + "columns": [ + "cej_id" + ], + "isUnique": true + }, + "users_created_at_idx": { + "name": "users_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + }, + "users_email_idx": { + "name": "users_email_idx", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "users_rels": { + "name": "users_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "media_id": { + "name": "media_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tags_id": { + "name": "tags_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_rels_order_idx": { + "name": "users_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "users_rels_parent_idx": { + "name": "users_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "users_rels_path_idx": { + "name": "users_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "users_rels_parent_id_users_id_fk": { + "name": "users_rels_parent_id_users_id_fk", + "tableFrom": "users_rels", + "tableTo": "users", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "users_rels_media_id_media_id_fk": { + "name": "users_rels_media_id_media_id_fk", + "tableFrom": "users_rels", + "tableTo": "media", + "columnsFrom": [ + "media_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "users_rels_tags_id_tags_id_fk": { + "name": "users_rels_tags_id_tags_id_fk", + "tableFrom": "users_rels", + "tableTo": "tags", + "columnsFrom": [ + "tags_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "supervisors": { + "name": "supervisors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "cgu": { + "name": "cgu", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "enum_supervisors_kind", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "email": { + "name": "email", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "reset_password_token": { + "name": "reset_password_token", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "reset_password_expiration": { + "name": "reset_password_expiration", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "salt": { + "name": "salt", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "hash": { + "name": "hash", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "login_attempts": { + "name": "login_attempts", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "lock_until": { + "name": "lock_until", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "supervisors_created_at_idx": { + "name": "supervisors_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + }, + "supervisors_email_idx": { + "name": "supervisors_email_idx", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "permissions": { + "name": "permissions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "phone_number": { + "name": "phone_number", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "supervisorKind": { + "name": "supervisorKind", + "type": "enum_permissions_supervisor_kind", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "permissions_phone_number_idx": { + "name": "permissions_phone_number_idx", + "columns": [ + "phone_number" + ], + "isUnique": true + }, + "permissions_created_at_idx": { + "name": "permissions_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "permissions_rels": { + "name": "permissions_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "supervisors_id": { + "name": "supervisors_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "permissions_rels_order_idx": { + "name": "permissions_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "permissions_rels_parent_idx": { + "name": "permissions_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "permissions_rels_path_idx": { + "name": "permissions_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "permissions_rels_parent_id_permissions_id_fk": { + "name": "permissions_rels_parent_id_permissions_id_fk", + "tableFrom": "permissions_rels", + "tableTo": "permissions", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "permissions_rels_supervisors_id_supervisors_id_fk": { + "name": "permissions_rels_supervisors_id_supervisors_id_fk", + "tableFrom": "permissions_rels", + "tableTo": "supervisors", + "columnsFrom": [ + "supervisors_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "apikeys": { + "name": "apikeys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "key": { + "name": "key", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "apikeys_key_idx": { + "name": "apikeys_key_idx", + "columns": [ + "key" + ], + "isUnique": true + }, + "apikeys_created_at_idx": { + "name": "apikeys_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "categories": { + "name": "categories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "text_white": { + "name": "text_white", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "categories_slug_idx": { + "name": "categories_slug_idx", + "columns": [ + "slug" + ], + "isUnique": true + }, + "categories_created_at_idx": { + "name": "categories_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "categories_rels": { + "name": "categories_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "media_id": { + "name": "media_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "categories_rels_order_idx": { + "name": "categories_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "categories_rels_parent_idx": { + "name": "categories_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "categories_rels_path_idx": { + "name": "categories_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "categories_rels_parent_id_categories_id_fk": { + "name": "categories_rels_parent_id_categories_id_fk", + "tableFrom": "categories_rels", + "tableTo": "categories", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "categories_rels_media_id_media_id_fk": { + "name": "categories_rels_media_id_media_id_fk", + "tableFrom": "categories_rels", + "tableTo": "media", + "columnsFrom": [ + "media_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "tags": { + "name": "tags", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tags_slug_idx": { + "name": "tags_slug_idx", + "columns": [ + "slug" + ], + "isUnique": true + }, + "tags_created_at_idx": { + "name": "tags_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "tags_rels": { + "name": "tags_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "media_id": { + "name": "media_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "tags_rels_order_idx": { + "name": "tags_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "tags_rels_parent_idx": { + "name": "tags_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "tags_rels_path_idx": { + "name": "tags_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "tags_rels_parent_id_tags_id_fk": { + "name": "tags_rels_parent_id_tags_id_fk", + "tableFrom": "tags_rels", + "tableTo": "tags", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tags_rels_media_id_media_id_fk": { + "name": "tags_rels_media_id_media_id_fk", + "tableFrom": "tags_rels", + "tableTo": "media", + "columnsFrom": [ + "media_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "partners": { + "name": "partners", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "url": { + "name": "url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "stared": { + "name": "stared", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "partners_name_idx": { + "name": "partners_name_idx", + "columns": [ + "name" + ], + "isUnique": true + }, + "partners_created_at_idx": { + "name": "partners_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "partners_rels": { + "name": "partners_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "media_id": { + "name": "media_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "partners_rels_order_idx": { + "name": "partners_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "partners_rels_parent_idx": { + "name": "partners_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "partners_rels_path_idx": { + "name": "partners_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "partners_rels_parent_id_partners_id_fk": { + "name": "partners_rels_parent_id_partners_id_fk", + "tableFrom": "partners_rels", + "tableTo": "partners", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "partners_rels_media_id_media_id_fk": { + "name": "partners_rels_media_id_media_id_fk", + "tableFrom": "partners_rels", + "tableTo": "media", + "columnsFrom": [ + "media_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "media": { + "name": "media", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "alt": { + "name": "alt", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "url": { + "name": "url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "filename": { + "name": "filename", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "mime_type": { + "name": "mime_type", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "filesize": { + "name": "filesize", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "width": { + "name": "width", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "height": { + "name": "height", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "focal_x": { + "name": "focal_x", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "focal_y": { + "name": "focal_y", + "type": "numeric", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "media_created_at_idx": { + "name": "media_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + }, + "media_filename_idx": { + "name": "media_filename_idx", + "columns": [ + "filename" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "offers_terms_of_use": { + "name": "offers_terms_of_use", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "is_highlighted": { + "name": "is_highlighted", + "type": "boolean", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "offers_terms_of_use_order_idx": { + "name": "offers_terms_of_use_order_idx", + "columns": [ + "_order" + ], + "isUnique": false + }, + "offers_terms_of_use_parent_id_idx": { + "name": "offers_terms_of_use_parent_id_idx", + "columns": [ + "_parent_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "offers_terms_of_use__parent_id_offers_id_fk": { + "name": "offers_terms_of_use__parent_id_offers_id_fk", + "tableFrom": "offers_terms_of_use", + "tableTo": "offers", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "offers_conditions": { + "name": "offers_conditions", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "text": { + "name": "text", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "offers_conditions_order_idx": { + "name": "offers_conditions_order_idx", + "columns": [ + "_order" + ], + "isUnique": false + }, + "offers_conditions_parent_id_idx": { + "name": "offers_conditions_parent_id_idx", + "columns": [ + "_parent_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "offers_conditions__parent_id_offers_id_fk": { + "name": "offers_conditions__parent_id_offers_id_fk", + "tableFrom": "offers_conditions", + "tableTo": "offers", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "offers_condition_blocks": { + "name": "offers_condition_blocks", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "offers_condition_blocks_order_idx": { + "name": "offers_condition_blocks_order_idx", + "columns": [ + "_order" + ], + "isUnique": false + }, + "offers_condition_blocks_parent_id_idx": { + "name": "offers_condition_blocks_parent_id_idx", + "columns": [ + "_parent_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "offers_condition_blocks__parent_id_offers_id_fk": { + "name": "offers_condition_blocks__parent_id_offers_id_fk", + "tableFrom": "offers_condition_blocks", + "tableTo": "offers", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "offers_articles": { + "name": "offers_articles", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "available": { + "name": "available", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "reference": { + "name": "reference", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "reduction_percentage": { + "name": "reduction_percentage", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "validity_to": { + "name": "validity_to", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "enum_offers_articles_kind", + "primaryKey": false, + "notNull": false + }, + "minimum_price": { + "name": "minimum_price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "maximum_price": { + "name": "maximum_price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "public_price": { + "name": "public_price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "price": { + "name": "price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "obiz_json": { + "name": "obiz_json", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "offers_articles_order_idx": { + "name": "offers_articles_order_idx", + "columns": [ + "_order" + ], + "isUnique": false + }, + "offers_articles_parent_id_idx": { + "name": "offers_articles_parent_id_idx", + "columns": [ + "_parent_id" + ], + "isUnique": false + }, + "offers_articles_reference_idx": { + "name": "offers_articles_reference_idx", + "columns": [ + "reference" + ], + "isUnique": true + } + }, + "foreignKeys": { + "offers_articles__parent_id_offers_id_fk": { + "name": "offers_articles__parent_id_offers_id_fk", + "tableFrom": "offers_articles", + "tableTo": "offers", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "offers": { + "name": "offers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "formated_title": { + "name": "formated_title", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "subtitle": { + "name": "subtitle", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "validity_from": { + "name": "validity_from", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "validity_to": { + "name": "validity_to", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true + }, + "published": { + "name": "published", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "enum_offers_source", + "primaryKey": false, + "notNull": true + }, + "obiz_id": { + "name": "obiz_id", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "nb_of_eligible_stores": { + "name": "nb_of_eligible_stores", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "link_of_eligible_stores": { + "name": "link_of_eligible_stores", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "barcodeFormat": { + "name": "barcodeFormat", + "type": "enum_offers_barcode_format", + "primaryKey": false, + "notNull": false + }, + "nb_seen": { + "name": "nb_seen", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "offers_created_at_idx": { + "name": "offers_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "offers_rels": { + "name": "offers_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "partners_id": { + "name": "partners_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "categories_id": { + "name": "categories_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tags_id": { + "name": "tags_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "media_id": { + "name": "media_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "offers_rels_order_idx": { + "name": "offers_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "offers_rels_parent_idx": { + "name": "offers_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "offers_rels_path_idx": { + "name": "offers_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "offers_rels_parent_id_offers_id_fk": { + "name": "offers_rels_parent_id_offers_id_fk", + "tableFrom": "offers_rels", + "tableTo": "offers", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "offers_rels_partners_id_partners_id_fk": { + "name": "offers_rels_partners_id_partners_id_fk", + "tableFrom": "offers_rels", + "tableTo": "partners", + "columnsFrom": [ + "partners_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "offers_rels_categories_id_categories_id_fk": { + "name": "offers_rels_categories_id_categories_id_fk", + "tableFrom": "offers_rels", + "tableTo": "categories", + "columnsFrom": [ + "categories_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "offers_rels_tags_id_tags_id_fk": { + "name": "offers_rels_tags_id_tags_id_fk", + "tableFrom": "offers_rels", + "tableTo": "tags", + "columnsFrom": [ + "tags_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "offers_rels_media_id_media_id_fk": { + "name": "offers_rels_media_id_media_id_fk", + "tableFrom": "offers_rels", + "tableTo": "media", + "columnsFrom": [ + "media_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "coupons": { + "name": "coupons", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "code": { + "name": "code", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "used": { + "name": "used", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "assign_user_at": { + "name": "assign_user_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "coupons_created_at_idx": { + "name": "coupons_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "coupons_rels": { + "name": "coupons_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "users_id": { + "name": "users_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "offers_id": { + "name": "offers_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "coupons_rels_order_idx": { + "name": "coupons_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "coupons_rels_parent_idx": { + "name": "coupons_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "coupons_rels_path_idx": { + "name": "coupons_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "coupons_rels_parent_id_coupons_id_fk": { + "name": "coupons_rels_parent_id_coupons_id_fk", + "tableFrom": "coupons_rels", + "tableTo": "coupons", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "coupons_rels_users_id_users_id_fk": { + "name": "coupons_rels_users_id_users_id_fk", + "tableFrom": "coupons_rels", + "tableTo": "users", + "columnsFrom": [ + "users_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "coupons_rels_offers_id_offers_id_fk": { + "name": "coupons_rels_offers_id_offers_id_fk", + "tableFrom": "coupons_rels", + "tableTo": "offers", + "columnsFrom": [ + "offers_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "orders_articles": { + "name": "orders_articles", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "article_reference": { + "name": "article_reference", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "article_quantity": { + "name": "article_quantity", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "article_montant": { + "name": "article_montant", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "orders_articles_order_idx": { + "name": "orders_articles_order_idx", + "columns": [ + "_order" + ], + "isUnique": false + }, + "orders_articles_parent_id_idx": { + "name": "orders_articles_parent_id_idx", + "columns": [ + "_parent_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "orders_articles__parent_id_orders_id_fk": { + "name": "orders_articles__parent_id_orders_id_fk", + "tableFrom": "orders_articles", + "tableTo": "orders", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "orders": { + "name": "orders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "number": { + "name": "number", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "enum_orders_status", + "primaryKey": false, + "notNull": true + }, + "obiz_status": { + "name": "obiz_status", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "payment_url": { + "name": "payment_url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "orders_number_idx": { + "name": "orders_number_idx", + "columns": [ + "number" + ], + "isUnique": true + }, + "orders_created_at_idx": { + "name": "orders_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "orders_rels": { + "name": "orders_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "users_id": { + "name": "users_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "offers_id": { + "name": "offers_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "media_id": { + "name": "media_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "orders_rels_order_idx": { + "name": "orders_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "orders_rels_parent_idx": { + "name": "orders_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "orders_rels_path_idx": { + "name": "orders_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "orders_rels_parent_id_orders_id_fk": { + "name": "orders_rels_parent_id_orders_id_fk", + "tableFrom": "orders_rels", + "tableTo": "orders", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "orders_rels_users_id_users_id_fk": { + "name": "orders_rels_users_id_users_id_fk", + "tableFrom": "orders_rels", + "tableTo": "users", + "columnsFrom": [ + "users_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "orders_rels_offers_id_offers_id_fk": { + "name": "orders_rels_offers_id_offers_id_fk", + "tableFrom": "orders_rels", + "tableTo": "offers", + "columnsFrom": [ + "offers_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "orders_rels_media_id_media_id_fk": { + "name": "orders_rels_media_id_media_id_fk", + "tableFrom": "orders_rels", + "tableTo": "media", + "columnsFrom": [ + "media_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "savings": { + "name": "savings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "savings_created_at_idx": { + "name": "savings_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "savings_rels": { + "name": "savings_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "coupons_id": { + "name": "coupons_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "savings_rels_order_idx": { + "name": "savings_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "savings_rels_parent_idx": { + "name": "savings_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "savings_rels_path_idx": { + "name": "savings_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "savings_rels_parent_id_savings_id_fk": { + "name": "savings_rels_parent_id_savings_id_fk", + "tableFrom": "savings_rels", + "tableTo": "savings", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "savings_rels_coupons_id_coupons_id_fk": { + "name": "savings_rels_coupons_id_coupons_id_fk", + "tableFrom": "savings_rels", + "tableTo": "coupons", + "columnsFrom": [ + "coupons_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "ordersignals": { + "name": "ordersignals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ordersignals_created_at_idx": { + "name": "ordersignals_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "ordersignals_rels": { + "name": "ordersignals_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "orders_id": { + "name": "orders_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "ordersignals_rels_order_idx": { + "name": "ordersignals_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "ordersignals_rels_parent_idx": { + "name": "ordersignals_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "ordersignals_rels_path_idx": { + "name": "ordersignals_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "ordersignals_rels_parent_id_ordersignals_id_fk": { + "name": "ordersignals_rels_parent_id_ordersignals_id_fk", + "tableFrom": "ordersignals_rels", + "tableTo": "ordersignals", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ordersignals_rels_orders_id_orders_id_fk": { + "name": "ordersignals_rels_orders_id_orders_id_fk", + "tableFrom": "ordersignals_rels", + "tableTo": "orders", + "columnsFrom": [ + "orders_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "app_version": { + "name": "app_version", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notifications_created_at_idx": { + "name": "notifications_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "notifications_rels": { + "name": "notifications_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "users_id": { + "name": "users_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "offers_id": { + "name": "offers_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "notifications_rels_order_idx": { + "name": "notifications_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "notifications_rels_parent_idx": { + "name": "notifications_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "notifications_rels_path_idx": { + "name": "notifications_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "notifications_rels_parent_id_notifications_id_fk": { + "name": "notifications_rels_parent_id_notifications_id_fk", + "tableFrom": "notifications_rels", + "tableTo": "notifications", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_rels_users_id_users_id_fk": { + "name": "notifications_rels_users_id_users_id_fk", + "tableFrom": "notifications_rels", + "tableTo": "users", + "columnsFrom": [ + "users_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_rels_offers_id_offers_id_fk": { + "name": "notifications_rels_offers_id_offers_id_fk", + "tableFrom": "notifications_rels", + "tableTo": "offers", + "columnsFrom": [ + "offers_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "search_requests": { + "name": "search_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "search_requests_name_idx": { + "name": "search_requests_name_idx", + "columns": [ + "name" + ], + "isUnique": true + }, + "search_requests_created_at_idx": { + "name": "search_requests_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "email_auth_tokens": { + "name": "email_auth_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "expiration": { + "name": "expiration", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_auth_tokens_created_at_idx": { + "name": "email_auth_tokens_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "email_auth_tokens_rels": { + "name": "email_auth_tokens_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "users_id": { + "name": "users_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "email_auth_tokens_rels_order_idx": { + "name": "email_auth_tokens_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "email_auth_tokens_rels_parent_idx": { + "name": "email_auth_tokens_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "email_auth_tokens_rels_path_idx": { + "name": "email_auth_tokens_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "email_auth_tokens_rels_parent_id_email_auth_tokens_id_fk": { + "name": "email_auth_tokens_rels_parent_id_email_auth_tokens_id_fk", + "tableFrom": "email_auth_tokens_rels", + "tableTo": "email_auth_tokens", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "email_auth_tokens_rels_users_id_users_id_fk": { + "name": "email_auth_tokens_rels_users_id_users_id_fk", + "tableFrom": "email_auth_tokens_rels", + "tableTo": "users", + "columnsFrom": [ + "users_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "payload_preferences": { + "name": "payload_preferences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "key": { + "name": "key", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payload_preferences_key_idx": { + "name": "payload_preferences_key_idx", + "columns": [ + "key" + ], + "isUnique": false + }, + "payload_preferences_created_at_idx": { + "name": "payload_preferences_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "payload_preferences_rels": { + "name": "payload_preferences_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "admins_id": { + "name": "admins_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "users_id": { + "name": "users_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "supervisors_id": { + "name": "supervisors_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "payload_preferences_rels_order_idx": { + "name": "payload_preferences_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "payload_preferences_rels_parent_idx": { + "name": "payload_preferences_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "payload_preferences_rels_path_idx": { + "name": "payload_preferences_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "payload_preferences_rels_parent_id_payload_preferences_id_fk": { + "name": "payload_preferences_rels_parent_id_payload_preferences_id_fk", + "tableFrom": "payload_preferences_rels", + "tableTo": "payload_preferences", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_preferences_rels_admins_id_admins_id_fk": { + "name": "payload_preferences_rels_admins_id_admins_id_fk", + "tableFrom": "payload_preferences_rels", + "tableTo": "admins", + "columnsFrom": [ + "admins_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_preferences_rels_users_id_users_id_fk": { + "name": "payload_preferences_rels_users_id_users_id_fk", + "tableFrom": "payload_preferences_rels", + "tableTo": "users", + "columnsFrom": [ + "users_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_preferences_rels_supervisors_id_supervisors_id_fk": { + "name": "payload_preferences_rels_supervisors_id_supervisors_id_fk", + "tableFrom": "payload_preferences_rels", + "tableTo": "supervisors", + "columnsFrom": [ + "supervisors_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "payload_migrations": { + "name": "payload_migrations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "batch": { + "name": "batch", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payload_migrations_created_at_idx": { + "name": "payload_migrations_created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "quick_access_items": { + "name": "quick_access_items", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + } + }, + "indexes": { + "quick_access_items_order_idx": { + "name": "quick_access_items_order_idx", + "columns": [ + "_order" + ], + "isUnique": false + }, + "quick_access_items_parent_id_idx": { + "name": "quick_access_items_parent_id_idx", + "columns": [ + "_parent_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "quick_access_items__parent_id_quick_access_id_fk": { + "name": "quick_access_items__parent_id_quick_access_id_fk", + "tableFrom": "quick_access_items", + "tableTo": "quick_access", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "quick_access": { + "name": "quick_access", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "quick_access_rels": { + "name": "quick_access_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "partners_id": { + "name": "partners_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "offers_id": { + "name": "offers_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "quick_access_rels_order_idx": { + "name": "quick_access_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "quick_access_rels_parent_idx": { + "name": "quick_access_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "quick_access_rels_path_idx": { + "name": "quick_access_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "quick_access_rels_parent_id_quick_access_id_fk": { + "name": "quick_access_rels_parent_id_quick_access_id_fk", + "tableFrom": "quick_access_rels", + "tableTo": "quick_access", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "quick_access_rels_partners_id_partners_id_fk": { + "name": "quick_access_rels_partners_id_partners_id_fk", + "tableFrom": "quick_access_rels", + "tableTo": "partners", + "columnsFrom": [ + "partners_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "quick_access_rels_offers_id_offers_id_fk": { + "name": "quick_access_rels_offers_id_offers_id_fk", + "tableFrom": "quick_access_rels", + "tableTo": "offers", + "columnsFrom": [ + "offers_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "landing_partners_items": { + "name": "landing_partners_items", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + } + }, + "indexes": { + "landing_partners_items_order_idx": { + "name": "landing_partners_items_order_idx", + "columns": [ + "_order" + ], + "isUnique": false + }, + "landing_partners_items_parent_id_idx": { + "name": "landing_partners_items_parent_id_idx", + "columns": [ + "_parent_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "landing_partners_items__parent_id_landing_partners_id_fk": { + "name": "landing_partners_items__parent_id_landing_partners_id_fk", + "tableFrom": "landing_partners_items", + "tableTo": "landing_partners", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "landing_partners": { + "name": "landing_partners", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "landing_partners_rels": { + "name": "landing_partners_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "partners_id": { + "name": "partners_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "landing_partners_rels_order_idx": { + "name": "landing_partners_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "landing_partners_rels_parent_idx": { + "name": "landing_partners_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "landing_partners_rels_path_idx": { + "name": "landing_partners_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "landing_partners_rels_parent_id_landing_partners_id_fk": { + "name": "landing_partners_rels_parent_id_landing_partners_id_fk", + "tableFrom": "landing_partners_rels", + "tableTo": "landing_partners", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "landing_partners_rels_partners_id_partners_id_fk": { + "name": "landing_partners_rels_partners_id_partners_id_fk", + "tableFrom": "landing_partners_rels", + "tableTo": "partners", + "columnsFrom": [ + "partners_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "landing_f_a_q_items": { + "name": "landing_f_a_q_items", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "varchar", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "landing_f_a_q_items_order_idx": { + "name": "landing_f_a_q_items_order_idx", + "columns": [ + "_order" + ], + "isUnique": false + }, + "landing_f_a_q_items_parent_id_idx": { + "name": "landing_f_a_q_items_parent_id_idx", + "columns": [ + "_parent_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "landing_f_a_q_items__parent_id_landing_f_a_q_id_fk": { + "name": "landing_f_a_q_items__parent_id_landing_f_a_q_id_fk", + "tableFrom": "landing_f_a_q_items", + "tableTo": "landing_f_a_q", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "landing_f_a_q": { + "name": "landing_f_a_q", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "new_category_items": { + "name": "new_category_items", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + } + }, + "indexes": { + "new_category_items_order_idx": { + "name": "new_category_items_order_idx", + "columns": [ + "_order" + ], + "isUnique": false + }, + "new_category_items_parent_id_idx": { + "name": "new_category_items_parent_id_idx", + "columns": [ + "_parent_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "new_category_items__parent_id_new_category_id_fk": { + "name": "new_category_items__parent_id_new_category_id_fk", + "tableFrom": "new_category_items", + "tableTo": "new_category", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "new_category": { + "name": "new_category", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "label": { + "name": "label", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "new_category_rels": { + "name": "new_category_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "media_id": { + "name": "media_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "offers_id": { + "name": "offers_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "new_category_rels_order_idx": { + "name": "new_category_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "new_category_rels_parent_idx": { + "name": "new_category_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "new_category_rels_path_idx": { + "name": "new_category_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "new_category_rels_parent_id_new_category_id_fk": { + "name": "new_category_rels_parent_id_new_category_id_fk", + "tableFrom": "new_category_rels", + "tableTo": "new_category", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "new_category_rels_media_id_media_id_fk": { + "name": "new_category_rels_media_id_media_id_fk", + "tableFrom": "new_category_rels", + "tableTo": "media", + "columnsFrom": [ + "media_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "new_category_rels_offers_id_offers_id_fk": { + "name": "new_category_rels_offers_id_offers_id_fk", + "tableFrom": "new_category_rels", + "tableTo": "offers", + "columnsFrom": [ + "offers_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "categories_list_items": { + "name": "categories_list_items", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + } + }, + "indexes": { + "categories_list_items_order_idx": { + "name": "categories_list_items_order_idx", + "columns": [ + "_order" + ], + "isUnique": false + }, + "categories_list_items_parent_id_idx": { + "name": "categories_list_items_parent_id_idx", + "columns": [ + "_parent_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "categories_list_items__parent_id_categories_list_id_fk": { + "name": "categories_list_items__parent_id_categories_list_id_fk", + "tableFrom": "categories_list_items", + "tableTo": "categories_list", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "categories_list": { + "name": "categories_list", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "categories_list_rels": { + "name": "categories_list_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "categories_id": { + "name": "categories_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "categories_list_rels_order_idx": { + "name": "categories_list_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "categories_list_rels_parent_idx": { + "name": "categories_list_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "categories_list_rels_path_idx": { + "name": "categories_list_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "categories_list_rels_parent_id_categories_list_id_fk": { + "name": "categories_list_rels_parent_id_categories_list_id_fk", + "tableFrom": "categories_list_rels", + "tableTo": "categories_list", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "categories_list_rels_categories_id_categories_id_fk": { + "name": "categories_list_rels_categories_id_categories_id_fk", + "tableFrom": "categories_list_rels", + "tableTo": "categories", + "columnsFrom": [ + "categories_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "tags_list_items": { + "name": "tags_list_items", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + } + }, + "indexes": { + "tags_list_items_order_idx": { + "name": "tags_list_items_order_idx", + "columns": [ + "_order" + ], + "isUnique": false + }, + "tags_list_items_parent_id_idx": { + "name": "tags_list_items_parent_id_idx", + "columns": [ + "_parent_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "tags_list_items__parent_id_tags_list_id_fk": { + "name": "tags_list_items__parent_id_tags_list_id_fk", + "tableFrom": "tags_list_items", + "tableTo": "tags_list", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "tags_list": { + "name": "tags_list", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "tags_list_rels": { + "name": "tags_list_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "tags_id": { + "name": "tags_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "tags_list_rels_order_idx": { + "name": "tags_list_rels_order_idx", + "columns": [ + "order" + ], + "isUnique": false + }, + "tags_list_rels_parent_idx": { + "name": "tags_list_rels_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + }, + "tags_list_rels_path_idx": { + "name": "tags_list_rels_path_idx", + "columns": [ + "path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "tags_list_rels_parent_id_tags_list_id_fk": { + "name": "tags_list_rels_parent_id_tags_list_id_fk", + "tableFrom": "tags_list_rels", + "tableTo": "tags_list", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tags_list_rels_tags_id_tags_id_fk": { + "name": "tags_list_rels_tags_id_tags_id_fk", + "tableFrom": "tags_list_rels", + "tableTo": "tags", + "columnsFrom": [ + "tags_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": { + "_locales": { + "name": "_locales", + "values": { + "fr": "fr" + } + }, + "enum_users_civility": { + "name": "enum_users_civility", + "values": { + "man": "man", + "woman": "woman" + } + }, + "enum_users_cej_from": { + "name": "enum_users_cej_from", + "values": { + "franceTravail": "franceTravail", + "missionLocale": "missionLocale", + "serviceCivique": "serviceCivique", + "ecole2ndeChance": "ecole2ndeChance", + "epide": "epide" + } + }, + "enum_users_time_at_c_e_j": { + "name": "enum_users_time_at_c_e_j", + "values": { + "started": "started", + "lessThan3Months": "lessThan3Months", + "moreThan3Months": "moreThan3Months" + } + }, + "enum_users_has_a_job_idea": { + "name": "enum_users_has_a_job_idea", + "values": { + "yes": "yes", + "no": "no" + } + }, + "enum_users_status_image": { + "name": "enum_users_status_image", + "values": { + "pending": "pending", + "approved": "approved" + } + }, + "enum_users_notification_status": { + "name": "enum_users_notification_status", + "values": { + "enabled": "enabled", + "disabled": "disabled" + } + }, + "enum_supervisors_kind": { + "name": "enum_supervisors_kind", + "values": { + "ML": "ML", + "SC": "SC", + "FT": "FT" + } + }, + "enum_permissions_supervisor_kind": { + "name": "enum_permissions_supervisor_kind", + "values": { + "ML": "ML", + "SC": "SC", + "FT": "FT" + } + }, + "enum_offers_source": { + "name": "enum_offers_source", + "values": { + "cje": "cje", + "obiz": "obiz" + } + }, + "enum_offers_barcode_format": { + "name": "enum_offers_barcode_format", + "values": { + "CODE39": "CODE39", + "EAN13": "EAN13", + "ITF14": "ITF14", + "MSI": "MSI", + "pharmacode": "pharmacode", + "codabar": "codabar", + "upc": "upc" + } + }, + "enum_offers_articles_kind": { + "name": "enum_offers_articles_kind", + "values": { + "variable_price": "variable_price", + "fixed_price": "fixed_price" + } + }, + "enum_orders_status": { + "name": "enum_orders_status", + "values": { + "awaiting_payment": "awaiting_payment", + "payment_completed": "payment_completed", + "delivered": "delivered", + "archived": "archived" + } + } + }, + "schemas": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + } +} \ No newline at end of file diff --git a/webapp/src/payload/migrations/20241107_154204.ts b/webapp/src/payload/migrations/20241107_154204.ts new file mode 100644 index 00000000..030bfd1b --- /dev/null +++ b/webapp/src/payload/migrations/20241107_154204.ts @@ -0,0 +1,46 @@ +import { MigrateUpArgs, MigrateDownArgs } from '@payloadcms/db-postgres' +import { sql } from 'drizzle-orm' + +export async function up({ payload }: MigrateUpArgs): Promise { +await payload.db.drizzle.execute(sql` + +CREATE TABLE IF NOT EXISTS "ordersignals" ( + "id" serial PRIMARY KEY NOT NULL, + "updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL, + "created_at" timestamp(3) with time zone DEFAULT now() NOT NULL +); + +CREATE TABLE IF NOT EXISTS "ordersignals_rels" ( + "id" serial PRIMARY KEY NOT NULL, + "order" integer, + "parent_id" integer NOT NULL, + "path" varchar NOT NULL, + "orders_id" integer +); + +CREATE INDEX IF NOT EXISTS "ordersignals_created_at_idx" ON "ordersignals" ("created_at"); +CREATE INDEX IF NOT EXISTS "ordersignals_rels_order_idx" ON "ordersignals_rels" ("order"); +CREATE INDEX IF NOT EXISTS "ordersignals_rels_parent_idx" ON "ordersignals_rels" ("parent_id"); +CREATE INDEX IF NOT EXISTS "ordersignals_rels_path_idx" ON "ordersignals_rels" ("path"); +DO $$ BEGIN + ALTER TABLE "ordersignals_rels" ADD CONSTRAINT "ordersignals_rels_parent_id_ordersignals_id_fk" FOREIGN KEY ("parent_id") REFERENCES "ordersignals"("id") ON DELETE cascade ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; + +DO $$ BEGIN + ALTER TABLE "ordersignals_rels" ADD CONSTRAINT "ordersignals_rels_orders_id_orders_id_fk" FOREIGN KEY ("orders_id") REFERENCES "orders"("id") ON DELETE cascade ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +`); + +}; + +export async function down({ payload }: MigrateDownArgs): Promise { +await payload.db.drizzle.execute(sql` + +DROP TABLE "ordersignals"; +DROP TABLE "ordersignals_rels";`); + +}; diff --git a/webapp/src/payload/payload-types.ts b/webapp/src/payload/payload-types.ts index 25cd32c6..56877aee 100644 --- a/webapp/src/payload/payload-types.ts +++ b/webapp/src/payload/payload-types.ts @@ -24,6 +24,7 @@ export interface Config { search_requests: SearchRequest; email_auth_tokens: EmailAuthToken; orders: Order; + ordersignals: Ordersignal; "payload-preferences": PayloadPreference; "payload-migrations": PayloadMigration; }; @@ -380,6 +381,16 @@ export interface Order { updatedAt: string; createdAt: string; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "ordersignals". + */ +export interface Ordersignal { + id: number; + order: number | Order; + updatedAt: string; + createdAt: string; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-preferences". diff --git a/webapp/src/payload/payload.config.ts b/webapp/src/payload/payload.config.ts index d74e333f..e44ea748 100644 --- a/webapp/src/payload/payload.config.ts +++ b/webapp/src/payload/payload.config.ts @@ -29,6 +29,7 @@ import { Tags } from "./collections/Tag"; import { SearchRequests } from "./collections/SearchRequest"; import { EmailAuthTokens } from "./collections/EmailAuthToken"; import { Orders } from "./collections/Order"; +import { OrderSignals } from "./collections/OrderSignal"; const adapter = s3Adapter({ config: { @@ -71,21 +72,22 @@ export default buildConfig({ }, collections: [ Admins, - ApiKeys, Users, Supervisors, Permissions, - Media, + ApiKeys, Categories, + Tags, Partners, + Media, Offers, Coupons, + Orders, Savings, + OrderSignals, Notifications, - Tags, SearchRequests, EmailAuthTokens, - Orders, ], localization: { locales: ["fr"], diff --git a/webapp/src/server/api/routers/order.ts b/webapp/src/server/api/routers/order.ts index 1e681cec..5abab6e1 100644 --- a/webapp/src/server/api/routers/order.ts +++ b/webapp/src/server/api/routers/order.ts @@ -356,4 +356,39 @@ export const orderRouter = createTRPCRouter({ return { data: order as OrderIncluded }; }), + + createSignal: userProtectedProcedure + .input( + z.object({ + id: z.number(), + }) + ) + .mutation(async ({ ctx, input }) => { + const { id } = input; + + const existingOrderSignals = await ctx.payload.find({ + collection: "ordersignals", + where: { + order: { equals: id }, + }, + }); + const existingOrderSignal = existingOrderSignals.docs[0]; + + if (!!existingOrderSignal) { + return { + data: existingOrderSignal, + }; + } + + const orderSignal = await ctx.payload.create({ + collection: "ordersignals", + data: { + order: id, + }, + }); + + return { + data: orderSignal, + }; + }), });