add: products api

This commit is contained in:
trisua 2025-08-07 13:52:48 -04:00
parent 3c4ce1fae5
commit df5eaf24f7
29 changed files with 1022 additions and 110 deletions

View file

@ -32,3 +32,5 @@ pub const CREATE_TABLE_DOMAINS: &str = include_str!("./sql/create_domains.sql");
pub const CREATE_TABLE_SERVICES: &str = include_str!("./sql/create_services.sql");
pub const CREATE_TABLE_APP_DATA: &str = include_str!("./sql/create_app_data.sql");
pub const CREATE_TABLE_LETTERS: &str = include_str!("./sql/create_letters.sql");
pub const CREATE_TABLE_TRANSFERS: &str = include_str!("./sql/create_transfers.sql");
pub const CREATE_TABLE_PRODUCTS: &str = include_str!("./sql/create_products.sql");

View file

@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS products (
id BIGINT NOT NULL PRIMARY KEY,
created BIGINT NOT NULL,
owner BIGINT NOT NULL,
title TEXT NOT NULL,
description TEXT NOT NULL,
method TEXT NOT NULL,
on_sale INT NOT NULL,
price INT NOT NULL,
stock INT NOT NULL
)

View file

@ -4,5 +4,6 @@ CREATE TABLE IF NOT EXISTS requests (
owner BIGINT NOT NULL,
action_type TEXT NOT NULL,
linked_asset BIGINT NOT NULL,
data TEXT NOT NULL,
PRIMARY KEY (id, owner, linked_asset)
)

View file

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS transfers (
id BIGINT NOT NULL PRIMARY KEY,
created BIGINT NOT NULL,
sender BIGINT NOT NULL,
receiver BIGINT NOT NULL,
amount INT NOT NULL,
is_pending INT NOT NULL,
method TEXT NOT NULL
)

View file

@ -37,3 +37,7 @@ DROP COLUMN IF EXISTS seller_data;
-- users coins
ALTER TABLE users
ADD COLUMN IF NOT EXISTS coins INT DEFAULT 0;
-- requests data
ALTER TABLE requests
ADD COLUMN IF NOT EXISTS data TEXT DEFAULT '"Null"';