feat: implement hero section with multi-trip booking widget and backend infrastructure
This commit is contained in:
parent
44995cb5db
commit
e7365b06ac
21 changed files with 4104 additions and 113 deletions
39
scripts/create_bookings_table.js
Normal file
39
scripts/create_bookings_table.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import mysql from "mysql2/promise";
|
||||
import "dotenv/config";
|
||||
|
||||
const run = async () => {
|
||||
const pool = mysql.createPool({
|
||||
host: process.env.DB_HOST || "localhost",
|
||||
user: process.env.DB_USER || "root",
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME || "roadrentals"
|
||||
});
|
||||
|
||||
try {
|
||||
console.log("Creating Bookings table...");
|
||||
|
||||
await pool.execute(`
|
||||
CREATE TABLE IF NOT EXISTS Bookings (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
trip_type VARCHAR(50) NOT NULL,
|
||||
pickup_location TEXT NOT NULL,
|
||||
drop_location TEXT,
|
||||
pickup_datetime DATETIME NOT NULL,
|
||||
return_datetime DATETIME,
|
||||
package_type VARCHAR(100),
|
||||
car_name VARCHAR(100),
|
||||
total_amount DECIMAL(10, 2),
|
||||
status VARCHAR(20) DEFAULT 'pending',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
)
|
||||
`);
|
||||
|
||||
console.log("Bookings table successfully created or already exists!");
|
||||
} catch (e) {
|
||||
console.error("Error creating table:", e.message);
|
||||
} finally {
|
||||
await pool.end();
|
||||
}
|
||||
};
|
||||
|
||||
run();
|
||||
35
scripts/create_leads_table.js
Normal file
35
scripts/create_leads_table.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import mysql from "mysql2/promise";
|
||||
import "dotenv/config";
|
||||
|
||||
const run = async () => {
|
||||
const pool = mysql.createPool({
|
||||
host: process.env.DB_HOST || "localhost",
|
||||
user: process.env.DB_USER || "root",
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME || "roadrentals"
|
||||
});
|
||||
|
||||
try {
|
||||
console.log("Creating Leads table...");
|
||||
|
||||
await pool.execute(`
|
||||
CREATE TABLE IF NOT EXISTS Leads (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
mobile_number VARCHAR(15) NOT NULL,
|
||||
trip_type VARCHAR(50),
|
||||
pickup_location TEXT,
|
||||
drop_location TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
)
|
||||
`);
|
||||
|
||||
console.log("Leads table successfully created!");
|
||||
} catch (e) {
|
||||
console.error("Error creating table:", e.message);
|
||||
} finally {
|
||||
await pool.end();
|
||||
}
|
||||
};
|
||||
|
||||
run();
|
||||
23
scripts/migrate_mobile_number.js
Normal file
23
scripts/migrate_mobile_number.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import mysql from "mysql2/promise";
|
||||
import "dotenv/config";
|
||||
|
||||
const run = async () => {
|
||||
const pool = mysql.createPool({
|
||||
host: process.env.DB_HOST || "localhost",
|
||||
user: process.env.DB_USER || "root",
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME || "roadrentals"
|
||||
});
|
||||
|
||||
try {
|
||||
console.log("Renaming column 'phone' to 'mobile_number'...");
|
||||
await pool.execute("ALTER TABLE User CHANGE COLUMN phone mobile_number VARCHAR(255) NOT NULL");
|
||||
console.log("Column successfully renamed!");
|
||||
} catch (e) {
|
||||
console.error("Error modifying table:", e.message);
|
||||
} finally {
|
||||
await pool.end();
|
||||
}
|
||||
};
|
||||
|
||||
run();
|
||||
Loading…
Add table
Add a link
Reference in a new issue