Skip to content

Commit

Permalink
add docker-compose && init db
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyKomarovCoder committed Oct 1, 2023
1 parent f65fe5c commit 44c3f68
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ services:
ports:
- 5433:5433
volumes:
- ./internal/common/postgresql/schema/:/docker-entrypoint-initdb.ds
- ./internal/common/postgresql/schema/:/docker-entrypoint-initdb.d/
16 changes: 13 additions & 3 deletions internal/common/postgresql/schema/initdb.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS Users
CREATE TABLE Users
(
id SERIAL PRIMARY KEY,
username VARCHAR(20) UNIQUE NOT NULL,
Expand All @@ -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);
8 changes: 4 additions & 4 deletions internal/models/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

0 comments on commit 44c3f68

Please sign in to comment.