Eniqlo is an markeplace inventory system that allow customer to buy products, and staff to add product inside the system
To install the boilerplate, follow these steps:
-
Make sure you download Golang, PostgreSQL, and migration package (go-migrate)
-
Clone this repository, make sure ssh is enable:
git clone git@github.com:Steve246/EniqloStore.git
-
Navigate to the project directory:
cd EniqloStore -
Run the vendor command to install dependencies:
go mod vendor
-
Run the program, after migration process is finished:
go mod run .
Uniqlo offers the following features:
-
Authentication:
- Staff registration
- Staff login
-
Product Management (CRUD):
- Create new products
- Get all products
- Update exisiting products
- Delete exisiting products
-
Search SKU:
- Get All Product from Customer
-
Checkout:
- Customer registration
- Get All customer data
- Customer Checkout
- Customer Checkout History (Coming Soon)
Database migration must use golang-migrate as a tool to manage database migration
-
Direct your terminal to your project folder first
-
Initiate folder
mkdir db/migrations
-
Create migration
migrate create -ext sql -dir db/migrations add_user_table
This command will create two new files named
add_user_table.up.sqlandadd_user_table.down.sqlinside thedb/migrationsfolder.up.sqlcan be filled with database queries to create / delete / change the table.down.sqlcan be filled with database queries to perform arollbackor return to the state before the table from.up.sqlwas created
-
Insert this querry, inside add_user_table.up.sql
CREATE TABLE staffdata (
id SERIAL PRIMARY KEY,
user_unique_id varchar(255) NOT NULL,
name VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
phone_number VARCHAR(255) NOT NULL,
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
deleted_at TIMESTAMP WITHOUT TIME ZONE
);
CREATE TABLE authentication(
id SERIAL PRIMARY KEY,
user_unique_id varchar(255),
token_auth varchar(255),
expire TIMESTAMP WITHOUT TIME ZONE
);
CREATE TABLE ProductList (
id SERIAL PRIMARY KEY,
name VARCHAR(30) NOT NULL,
sku VARCHAR(30) NOT NULL,
category VARCHAR(60) NOT NULL,
imageUrl VARCHAR(100) NOT NULL,
notes VARCHAR(200) NOT NULL,
price INT NOT NULL CHECK (price >= 0),
stock INT NOT NULL CHECK (stock >= 0 AND stock <= 100000),
location VARCHAR(200) NOT NULL,
isAvailable BOOLEAN NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP
);
- Insert this querry, inside add_user_table.down.sql
DROP TABLE IF EXISTS "staffdata", "authentication";
-
Execute migration
migrate -database "postgres://username:password@host:port/dbname?sslmode=disable" -path db/migrations up -
Rollback migration
migrate -database "postgres://username:password@host:port/dbname?sslmode=disable" -path db/migrations dow -
View the current migration state
migrate -database "postgres://username:password@host:port/dbname?sslmode=disable" version
