-- config/migrations.sql
-- Sample SQL script for creating core tables.

CREATE TABLE IF NOT EXISTS users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(255),
  email VARCHAR(255) UNIQUE,
  password VARCHAR(255),
  role ENUM('Admin', 'Manager', 'Staff') DEFAULT 'Manager',
  createdAt DATETIME DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS properties (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(255),
  address VARCHAR(255),
  type VARCHAR(100),
  amenities TEXT,
  ownerId INT,
  createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (ownerId) REFERENCES users(id)
);

CREATE TABLE IF NOT EXISTS bookings (
  id INT AUTO_INCREMENT PRIMARY KEY,
  propertyId INT,
  guestName VARCHAR(255),
  checkIn DATE,
  checkOut DATE,
  source VARCHAR(50),
  status VARCHAR(50) DEFAULT 'confirmed',
  ownerId INT,
  createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (propertyId) REFERENCES properties(id)
);

-- Additional tables for subscriptions, contacts, tasks, vendors, invoices, incomes, workflows, leads, etc.
