Add initial project structure with core functionality for book and stationery uploads
- Created main application entry point in `main.go`. - Added configuration management in `config/config.go` and tests in `config/config_test.go`. - Implemented handlers for book and stationery uploads in `handlers/book.go` and `handlers/stationery.go`, including validation logic. - Established database connection and services in `services/database.go` and `services/book_service.go`. - Defined models for books and stationery in `models/book.go` and `models/stationery.go`. - Set up Firebase integration for image uploads in `services/firebase.go`. - Created migration scripts for database schema in `migrations/001_create_tables.sql` and subsequent updates. - Added CORS and error handling middleware. - Included comprehensive tests for handlers, services, and utilities. - Documented API endpoints and usage in `README.md` and migration instructions in `migrations/README.md`. - Introduced `.gitignore` to exclude unnecessary files and directories. - Added Go module support with `go.mod` and `go.sum` files. - Implemented utility functions for slug generation and validation in `utils/slug.go` and `utils/validation.go`.
This commit is contained in:
46
migrations/001_create_tables.sql
Normal file
46
migrations/001_create_tables.sql
Normal file
@@ -0,0 +1,46 @@
|
||||
-- Create books table
|
||||
CREATE TABLE IF NOT EXISTS 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 IF NOT EXISTS idx_books_created_at ON books(created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_books_category ON books(category);
|
||||
CREATE INDEX IF NOT EXISTS idx_books_slug ON books(slug);
|
||||
|
||||
-- Create stationery table
|
||||
CREATE TABLE IF NOT EXISTS stationery (
|
||||
stationery_code UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
stationery_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,
|
||||
color VARCHAR(100),
|
||||
material VARCHAR(100),
|
||||
dimensions VARCHAR(100),
|
||||
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 stationery table
|
||||
CREATE INDEX IF NOT EXISTS idx_stationery_created_at ON stationery(created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_stationery_category ON stationery(category);
|
||||
CREATE INDEX IF NOT EXISTS idx_stationery_slug ON stationery(slug);
|
||||
|
||||
Reference in New Issue
Block a user