Skip to content

Commit 67cb587

Browse files
committed
feat: OOH Marketplace database WIP
1 parent db36222 commit 67cb587

16 files changed

+760
-1
lines changed

database/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ production.
2727

2828
Please report any bugs with generated code at
2929
[Sequelize UI Issues](https://github.com/tomjschuster/sequelize-ui/issues).
30+
31+
## OpenAI Threads
32+
33+
https://platform.openai.com/playground?assistant=asst_AZsE2NJRIC6IgPTecyIpExUP&mode=assistant&thread=thread_xqVBXkeEf4EhFQGp0R4r4vAe
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const { DataTypes } = require("sequelize");
2+
3+
module.exports = {
4+
up: async (queryInterface, Sequelize) => {
5+
await queryInterface.createTable("locations", {
6+
location_id: {
7+
type: DataTypes.UUID,
8+
primaryKey: true,
9+
unique: true,
10+
allowNull: false,
11+
defaultValue: Sequelize.literal("gen_random_uuid()"),
12+
},
13+
city: {
14+
type: DataTypes.STRING,
15+
allowNull: false,
16+
},
17+
state: {
18+
type: DataTypes.STRING,
19+
allowNull: false,
20+
},
21+
country: {
22+
type: DataTypes.STRING,
23+
allowNull: false,
24+
},
25+
latitude: {
26+
type: DataTypes.DOUBLE,
27+
allowNull: true,
28+
},
29+
longitude: {
30+
type: DataTypes.DOUBLE,
31+
allowNull: true,
32+
},
33+
landmark_proximity: {
34+
type: DataTypes.STRING,
35+
allowNull: true,
36+
},
37+
created_at: {
38+
type: DataTypes.DATE,
39+
allowNull: false,
40+
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
41+
},
42+
updated_at: {
43+
type: DataTypes.DATE,
44+
allowNull: false,
45+
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
46+
},
47+
});
48+
},
49+
down: async (queryInterface, Sequelize) => {
50+
await queryInterface.dropTable("locations");
51+
},
52+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
module.exports = {
2+
up: async (queryInterface) => {
3+
await queryInterface.bulkInsert("locations", [
4+
{
5+
city: "New York",
6+
state: "NY",
7+
country: "USA",
8+
latitude: 40.712776,
9+
longitude: -74.005974,
10+
},
11+
{
12+
city: "Los Angeles",
13+
state: "CA",
14+
country: "USA",
15+
latitude: 34.052235,
16+
longitude: -118.243683,
17+
},
18+
{
19+
city: "Chicago",
20+
state: "IL",
21+
country: "USA",
22+
latitude: 41.878113,
23+
longitude: -87.629799,
24+
},
25+
{
26+
city: "Houston",
27+
state: "TX",
28+
country: "USA",
29+
latitude: 29.760427,
30+
longitude: -95.369804,
31+
},
32+
{
33+
city: "Phoenix",
34+
state: "AZ",
35+
country: "USA",
36+
latitude: 33.448376,
37+
longitude: -112.074036,
38+
},
39+
{
40+
city: "Philadelphia",
41+
state: "PA",
42+
country: "USA",
43+
latitude: 39.952584,
44+
longitude: -75.165222,
45+
},
46+
{
47+
city: "San Antonio",
48+
state: "TX",
49+
country: "USA",
50+
latitude: 29.424122,
51+
longitude: -98.493629,
52+
},
53+
{
54+
city: "San Diego",
55+
state: "CA",
56+
country: "USA",
57+
latitude: 32.715736,
58+
longitude: -117.161087,
59+
},
60+
{
61+
city: "Dallas",
62+
state: "TX",
63+
country: "USA",
64+
latitude: 32.776664,
65+
longitude: -96.796988,
66+
},
67+
{
68+
city: "San Jose",
69+
state: "CA",
70+
country: "USA",
71+
latitude: 37.338207,
72+
longitude: -121.88633,
73+
},
74+
]);
75+
},
76+
down: async (queryInterface) => {
77+
await queryInterface.bulkDelete("locations", null, {});
78+
},
79+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const { DataTypes } = require("sequelize");
2+
3+
module.exports = {
4+
up: async (queryInterface, Sequelize) => {
5+
await queryInterface.createTable("formats", {
6+
format_id: {
7+
type: DataTypes.UUID,
8+
primaryKey: true,
9+
unique: true,
10+
allowNull: false,
11+
defaultValue: Sequelize.literal("gen_random_uuid()"),
12+
},
13+
type: {
14+
type: DataTypes.STRING,
15+
allowNull: false,
16+
},
17+
created_at: {
18+
type: DataTypes.DATE,
19+
allowNull: false,
20+
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
21+
},
22+
updated_at: {
23+
type: DataTypes.DATE,
24+
allowNull: false,
25+
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
26+
},
27+
});
28+
},
29+
down: async (queryInterface, Sequelize) => {
30+
await queryInterface.dropTable("formats");
31+
},
32+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const { QueryInterface } = require("sequelize");
2+
3+
module.exports = {
4+
up: async (queryInterface) => {
5+
await queryInterface.bulkInsert("formats", [
6+
{ type: "Billboard" },
7+
{ type: "Digital Screen" },
8+
{ type: "Transit Advertising" },
9+
{ type: "Street Furniture" },
10+
{ type: "Mobile Billboard" },
11+
{ type: "Airport Advertising" },
12+
{ type: "Place-Based Media" },
13+
{
14+
type: "Point of Sale Displays",
15+
},
16+
{
17+
type: "Wallscapes and Murals",
18+
},
19+
]);
20+
},
21+
down: async (queryInterface) => {
22+
await queryInterface.bulkDelete("formats", null, {});
23+
},
24+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { DataTypes } = require("sequelize");
2+
3+
module.exports = {
4+
up: async (queryInterface, Sequelize) => {
5+
await queryInterface.createTable("advertisers", {
6+
advertiser_id: {
7+
type: DataTypes.UUID,
8+
primaryKey: true,
9+
unique: true,
10+
allowNull: false,
11+
defaultValue: Sequelize.literal("gen_random_uuid()"), // Updated to use gen_random_uuid()
12+
},
13+
name: {
14+
type: DataTypes.STRING,
15+
allowNull: false,
16+
},
17+
industry: {
18+
type: DataTypes.STRING,
19+
allowNull: false,
20+
},
21+
preferred_demographics: {
22+
type: DataTypes.TEXT, // Use TEXT for potential JSON or extensive textual data.
23+
allowNull: true,
24+
},
25+
created_at: {
26+
type: DataTypes.DATE,
27+
allowNull: false,
28+
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
29+
},
30+
updated_at: {
31+
type: DataTypes.DATE,
32+
allowNull: false,
33+
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
34+
},
35+
});
36+
},
37+
down: async (queryInterface, Sequelize) => {
38+
await queryInterface.dropTable("advertisers");
39+
},
40+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const { DataTypes } = require("sequelize");
2+
3+
module.exports = {
4+
up: async (queryInterface, Sequelize) => {
5+
await queryInterface.createTable("audience_demographics", {
6+
demographics_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 audience demographic entry.",
13+
},
14+
name: {
15+
type: DataTypes.STRING,
16+
allowNull: false,
17+
comment: "Descriptive name or identifier for the demographic group.",
18+
},
19+
age_ranges: {
20+
type: DataTypes.TEXT, // Storing structured JSON data.
21+
allowNull: true,
22+
comment: "JSON string to store an array or object of age ranges interested.",
23+
},
24+
gender: {
25+
type: DataTypes.STRING,
26+
allowNull: true,
27+
comment: "Gender the demographic targets, if applicable.",
28+
},
29+
interests: {
30+
type: DataTypes.TEXT, // Storing structured JSON data.
31+
allowNull: true,
32+
comment: "JSON string to store an array of interests for the demographic.",
33+
},
34+
created_at: {
35+
type: DataTypes.DATE,
36+
allowNull: false,
37+
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
38+
comment: "Timestamp when the record was created.",
39+
},
40+
updated_at: {
41+
type: DataTypes.DATE,
42+
allowNull: false,
43+
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
44+
comment: "Timestamp when the record was last updated.",
45+
},
46+
});
47+
},
48+
49+
down: async (queryInterface, Sequelize) => {
50+
await queryInterface.dropTable("audience_demographics");
51+
},
52+
};

0 commit comments

Comments
 (0)