-- =====================================================
-- Powercode Panel — Database Schema
-- Import this file in phpMyAdmin / MySQL before running the portal
-- =====================================================

-- NOTE: Shared hosting (like yours) usually already creates the database
-- for you from cPanel — so this CREATE DATABASE line is commented out.
-- If you're on local XAMPP/WAMP, uncomment the line below.
-- CREATE DATABASE IF NOT EXISTS indserverco_powercode CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

USE indserverco_powercode;

-- -----------------------------------------------------
-- Table: users  (login ke liye)
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    full_name VARCHAR(100) NOT NULL,
    username VARCHAR(50) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB;

-- Default admin login:
--   username: admin
--   password: admin123
-- (password hashed via PHP password_hash — see create_admin.php)

-- -----------------------------------------------------
-- Table: clients
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS clients (
    id INT AUTO_INCREMENT PRIMARY KEY,
    client_name VARCHAR(150) NOT NULL,
    mobile VARCHAR(20) DEFAULT NULL,
    address VARCHAR(255) DEFAULT NULL,
    status ENUM('active','inactive') NOT NULL DEFAULT 'active',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB;

-- -----------------------------------------------------
-- Table: companies  (Companies / Freelancers)
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS companies (
    id INT AUTO_INCREMENT PRIMARY KEY,
    person_name VARCHAR(150) NOT NULL,
    company_name VARCHAR(150) DEFAULT NULL,
    mobile VARCHAR(20) DEFAULT NULL,
    address VARCHAR(255) DEFAULT NULL,
    status ENUM('active','inactive') NOT NULL DEFAULT 'active',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB;
