-- Drop the old books table if it exists with wrong schema
DROP TABLE IF EXISTS books CASCADE;

-- Recreate books table with correct schema
CREATE TABLE books (
    book_code UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    book_name VARCHAR(200) NOT NULL,
    cost DECIMAL(10,2) NOT NULL,
    price DECIMAL(10,2) NOT NULL,
    discount DECIMAL(10,2) DEFAULT 0,
    quantity INTEGER NOT NULL,
    publisher_author VARCHAR(200) NOT NULL,
    category VARCHAR(100) NOT NULL,
    description TEXT,
    image_url TEXT NOT NULL,
    slug VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT NOW(),
    updated_at TIMESTAMP DEFAULT NOW()
);

-- Create indexes for books table
CREATE INDEX idx_books_created_at ON books(created_at DESC);
CREATE INDEX idx_books_category ON books(category);
CREATE INDEX idx_books_slug ON books(slug);

