|
| 1 | +const { DataTypes } = require("sequelize"); |
| 2 | + |
| 3 | +module.exports = { |
| 4 | + up: async (queryInterface, Sequelize) => { |
| 5 | + await queryInterface.createTable("ooh_media", { |
| 6 | + media_id: { |
| 7 | + type: DataTypes.UUID, |
| 8 | + primaryKey: true, |
| 9 | + unique: true, |
| 10 | + allowNull: false, |
| 11 | + defaultValue: Sequelize.literal("gen_random_uuid()"), // Correct default value for generating UUIDs |
| 12 | + comment: "Unique identifier for each OOH media entry.", |
| 13 | + }, |
| 14 | + format_id: { |
| 15 | + type: DataTypes.UUID, |
| 16 | + references: { |
| 17 | + model: "formats", // References the 'formats' table |
| 18 | + key: "format_id", // References the 'format_id' primary key in 'formats' table |
| 19 | + }, |
| 20 | + onUpdate: "CASCADE", |
| 21 | + onDelete: "SET NULL", |
| 22 | + allowNull: false, |
| 23 | + comment: "Foreign key linking to the Formats table to specify the OOH format type.", |
| 24 | + }, |
| 25 | + location_id: { |
| 26 | + type: DataTypes.UUID, |
| 27 | + allowNull: false, |
| 28 | + comment: "Foreign key linking to the Locations table for geographical data.", |
| 29 | + references: { |
| 30 | + model: "locations", // References the 'locations' table |
| 31 | + key: "location_id", // References the 'location_id' primary key in 'locations' table |
| 32 | + }, |
| 33 | + onUpdate: "CASCADE", |
| 34 | + onDelete: "SET NULL", |
| 35 | + }, |
| 36 | + size: { |
| 37 | + type: DataTypes.TEXT, |
| 38 | + allowNull: false, |
| 39 | + comment: "Describes physical dimensions or digital resolution (as JSON string).", |
| 40 | + }, |
| 41 | + digital: { |
| 42 | + type: DataTypes.BOOLEAN, |
| 43 | + defaultValue: false, |
| 44 | + comment: "Indicates whether the OOH media is digital.", |
| 45 | + }, |
| 46 | + interactive_capabilities: { |
| 47 | + type: DataTypes.BOOLEAN, |
| 48 | + defaultValue: false, |
| 49 | + comment: "Specifies if the digital media supports interactive features.", |
| 50 | + }, |
| 51 | + visibility_score: { |
| 52 | + type: DataTypes.FLOAT, |
| 53 | + allowNull: true, |
| 54 | + comment: "A derived metric for estimating visibility or foot traffic.", |
| 55 | + }, |
| 56 | + availability_start_date: { |
| 57 | + type: DataTypes.DATEONLY, |
| 58 | + allowNull: false, |
| 59 | + comment: "Start date when the media is available for advertising.", |
| 60 | + }, |
| 61 | + availability_end_date: { |
| 62 | + type: DataTypes.DATEONLY, |
| 63 | + allowNull: false, |
| 64 | + comment: "End date until the media is available for advertising.", |
| 65 | + }, |
| 66 | + price: { |
| 67 | + type: DataTypes.FLOAT, |
| 68 | + allowNull: false, |
| 69 | + comment: "The cost of booking the media for advertising.", |
| 70 | + }, |
| 71 | + rating: { |
| 72 | + type: DataTypes.FLOAT, |
| 73 | + allowNull: true, |
| 74 | + comment: "Optional rating based on past campaign performances or quality assessments.", |
| 75 | + }, |
| 76 | + media_images: { |
| 77 | + type: DataTypes.TEXT, |
| 78 | + allowNull: true, |
| 79 | + comment: "JSON string containing URLs to images of the ad space.", |
| 80 | + }, |
| 81 | + created_at: { |
| 82 | + type: DataTypes.DATE, |
| 83 | + allowNull: false, |
| 84 | + defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"), |
| 85 | + comment: "Timestamp when the record was created.", |
| 86 | + }, |
| 87 | + updated_at: { |
| 88 | + type: DataTypes.DATE, |
| 89 | + allowNull: false, |
| 90 | + defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"), |
| 91 | + comment: "Timestamp when the record was last updated.", |
| 92 | + }, |
| 93 | + }); |
| 94 | + }, |
| 95 | + down: async (queryInterface, Sequelize) => { |
| 96 | + await queryInterface.dropTable("ooh_media"); |
| 97 | + }, |
| 98 | +}; |
0 commit comments