diff --git a/docker-compose.yml b/docker-compose.yml index f14a07cd..c7b8dcf0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,4 +14,4 @@ services: ports: - 5433:5433 volumes: - - ./internal/common/postgresql/schema/:/docker-entrypoint-initdb.ds \ No newline at end of file + - ./internal/common/postgresql/schema/:/docker-entrypoint-initdb.d/ \ No newline at end of file diff --git a/internal/common/postgresql/schema/initdb.sql b/internal/common/postgresql/schema/initdb.sql index 6d3c30e9..895e4125 100644 --- a/internal/common/postgresql/schema/initdb.sql +++ b/internal/common/postgresql/schema/initdb.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS Users +CREATE TABLE Users ( id SERIAL PRIMARY KEY, username VARCHAR(20) UNIQUE NOT NULL, @@ -8,9 +8,19 @@ CREATE TABLE IF NOT EXISTS Users avatar_url TEXT ); -CREATE TABLE IF NOT EXISTS Accounts ( +CREATE TABLE Accounts ( id UUID PRIMARY KEY, user_id INT, - balance NUMERIC, + balance money, mean_payment TEXT ); + + +INSERT INTO "users"(username, password_hash, first_name, last_name, avatar_url) +VALUES ('kosmatoff', 'hash', 'Дмитрий', 'Комаров', 'image/img1.png'); + +INSERT INTO "accounts"(UserID, Balance, MeanPayment) +VALUES (1, 'Карта', 25000); + +INSERT INTO "accounts"(UserID, Balance, MeanPayment) +VALUES (1, 'Наличные', 450); diff --git a/internal/models/account.go b/internal/models/account.go index 9b5528d6..41079990 100644 --- a/internal/models/account.go +++ b/internal/models/account.go @@ -3,8 +3,8 @@ package models import "github.com/google/uuid" type Accounts struct { - ID uuid.UUID `json:"id" db:"id"` - UserID uint `json:"user_id" db:"user_id"` - Balance float64 `json:"balance" db:"balance"` - MeanPayment string `json:"mean_payment" db:"mean_payment"` + ID uuid.UUID `json:"id"` + username uint `json:"user_id"` + Balance float64 `json:"balance"` + MeanPayment string `json:"mean_payment"` }