From d3e419c98b19fabb09ef274b0cb27460b5a19037 Mon Sep 17 00:00:00 2001 From: counterweight Date: Mon, 10 Mar 2025 13:54:08 +0100 Subject: [PATCH] offerdetailsset --- .../20250308000000-first-schema-tables.js | 64 +++++++++++++++++++ .../20250308000001-first-schema-fks.js | 10 +++ src/models/OfferDetailsSet.js | 2 +- 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/src/database/migrations/20250308000000-first-schema-tables.js b/src/database/migrations/20250308000000-first-schema-tables.js index 16c5456..8cb5e18 100644 --- a/src/database/migrations/20250308000000-first-schema-tables.js +++ b/src/database/migrations/20250308000000-first-schema-tables.js @@ -212,6 +212,70 @@ module.exports = { }, { transaction: t } ), + queryInterface.createTable( + 'offer_details_set', + { + uuid: { + type: Sequelize.UUID, + allowNull: false, + unique: true, + primaryKey: true, + }, + offer_uuid: { + type: Sequelize.UUID, + allowNull: false, + }, + wants: { + type: Sequelize.STRING, + allowNull: false, + }, + premium: { + type: Sequelize.DECIMAL(5, 2), + allowNull: false, + }, + trade_amount_eur: { + type: Sequelize.INTEGER, + allowNull: false, + }, + location_details: { + type: Sequelize.TEXT, + allowNull: false, + }, + time_availability_details: { + type: Sequelize.TEXT, + allowNull: false, + }, + show_offer_to_trusted: { + type: Sequelize.BOOLEAN, + allowNull: false, + }, + show_offer_to_trusted_trusted: { + type: Sequelize.BOOLEAN, + allowNull: false, + }, + show_offer_to_all_members: { + type: Sequelize.BOOLEAN, + allowNull: false, + }, + is_onchain_accepted: { + type: Sequelize.BOOLEAN, + allowNull: false, + }, + is_lightning_accepted: { + type: Sequelize.BOOLEAN, + allowNull: false, + }, + are_big_notes_accepted: { + type: Sequelize.BOOLEAN, + allowNull: false, + }, + created_at: { + type: Sequelize.DATE, + allowNull: false, + }, + }, + { transaction: t } + ), ]); }); }, diff --git a/src/database/migrations/20250308000001-first-schema-fks.js b/src/database/migrations/20250308000001-first-schema-fks.js index 79d1544..56137b2 100644 --- a/src/database/migrations/20250308000001-first-schema-fks.js +++ b/src/database/migrations/20250308000001-first-schema-fks.js @@ -43,6 +43,16 @@ module.exports = { onDelete: 'cascade', onUpdate: 'cascade', }), + queryInterface.addConstraint('offer_details_set', { + fields: ['offer_uuid'], + type: 'foreign key', + references: { + table: 'offer_created', + field: 'uuid', + }, + onDelete: 'cascade', + onUpdate: 'cascade', + }), ]); }); }, diff --git a/src/models/OfferDetailsSet.js b/src/models/OfferDetailsSet.js index 766f148..d2023d7 100644 --- a/src/models/OfferDetailsSet.js +++ b/src/models/OfferDetailsSet.js @@ -15,7 +15,7 @@ class OfferDetailsSetProvider { primaryKey: true, }, offer_uuid: { - type: this.DataTypes.STRING, + type: this.DataTypes.UUID, allowNull: false, }, wants: {