Very Good till Now !
This commit is contained in:
83
.TemporaryDocument/ PostgreSQL 작업.md
Normal file
83
.TemporaryDocument/ PostgreSQL 작업.md
Normal file
@@ -0,0 +1,83 @@
|
||||
gitea
|
||||
ubuntu@ubuntu-desktop:~/AssetPilot/asset_pilot_docker$ docker exec -it asset_pilot_db psql -U asset_user -d asset_pilot
|
||||
psql (16.11)
|
||||
Type "help" for help.
|
||||
|
||||
asset_pilot=# assetpilot
|
||||
asset_pilot-# \dt
|
||||
List of relations
|
||||
Schema | Name | Type | Owner
|
||||
--------+----------------+-------+------------
|
||||
public | alert_settings | table | asset_user
|
||||
public | assets | table | asset_user
|
||||
public | price_history | table | asset_user
|
||||
public | user_assets | table | asset_user
|
||||
(4 rows)
|
||||
|
||||
asset_pilot-# \d assets
|
||||
Table "public.assets"
|
||||
Column | Type | Collation | Nullable | Default
|
||||
------------+-----------------------------+-----------+----------+------------------------------------
|
||||
id | integer | | not null | nextval('assets_id_seq'::regclass)
|
||||
symbol | character varying(20) | | not null |
|
||||
name | character varying(100) | | not null |
|
||||
category | character varying(50) | | |
|
||||
created_at | timestamp without time zone | | |
|
||||
Indexes:
|
||||
"assets_pkey" PRIMARY KEY, btree (id)
|
||||
"ix_assets_id" btree (id)
|
||||
"ix_assets_symbol" UNIQUE, btree (symbol)
|
||||
Referenced by:
|
||||
TABLE "price_history" CONSTRAINT "price_history_asset_id_fkey" FOREIGN KEY (asset_id) REFERENCES assets(id)
|
||||
TABLE "user_assets" CONSTRAINT "user_assets_asset_id_fkey" FOREIGN KEY (asset_id) REFERENCES assets(id)
|
||||
|
||||
asset_pilot-# \d user_assets
|
||||
Table "public.user_assets"
|
||||
Column | Type | Collation | Nullable | Default
|
||||
----------------+-----------------------------+-----------+----------+-----------------------------------------
|
||||
id | integer | | not null | nextval('user_assets_id_seq'::regclass)
|
||||
asset_id | integer | | not null |
|
||||
previous_close | double precision | | |
|
||||
average_price | double precision | | |
|
||||
quantity | double precision | | |
|
||||
updated_at | timestamp without time zone | | |
|
||||
Indexes:
|
||||
"user_assets_pkey" PRIMARY KEY, btree (id)
|
||||
"ix_user_assets_id" btree (id)
|
||||
Foreign-key constraints:
|
||||
"user_assets_asset_id_fkey" FOREIGN KEY (asset_id) REFERENCES assets(id)
|
||||
|
||||
asset_pilot-# SELECT * FROM assets;
|
||||
ERROR: syntax error at or near "assetpilot"
|
||||
LINE 1: assetpilot
|
||||
^
|
||||
asset_pilot=# -- 현재 가격과 상태(up/down)를 저장할 컬럼 추가
|
||||
asset_pilot=# ALTER TABLE assets ADD COLUMN current_price DOUBLE PRECISION;
|
||||
ALTER TABLE
|
||||
asset_pilot=# ALTER TABLE assets ADD COLUMN price_state CHARACTER VARYING(20) DEFAULT 'stable';
|
||||
ALTER TABLE
|
||||
asset_pilot=# ALTER TABLE assets ADD COLUMN last_updated TIMESTAMP WITHOUT TIME ZONE;
|
||||
ALTER TABLE
|
||||
asset_pilot=#
|
||||
asset_pilot=# -- 잘 추가되었는지 확인
|
||||
asset_pilot=# \d assets
|
||||
Table "public.assets"
|
||||
Column | Type | Collation | Nullable | Default
|
||||
---------------+-----------------------------+-----------+----------+------------------------------------
|
||||
id | integer | | not null | nextval('assets_id_seq'::regclass)
|
||||
symbol | character varying(20) | | not null |
|
||||
name | character varying(100) | | not null |
|
||||
category | character varying(50) | | |
|
||||
created_at | timestamp without time zone | | |
|
||||
current_price | double precision | | |
|
||||
price_state | character varying(20) | | | 'stable'::character varying
|
||||
last_updated | timestamp without time zone | | |
|
||||
Indexes:
|
||||
"assets_pkey" PRIMARY KEY, btree (id)
|
||||
"ix_assets_id" btree (id)
|
||||
"ix_assets_symbol" UNIQUE, btree (symbol)
|
||||
Referenced by:
|
||||
TABLE "price_history" CONSTRAINT "price_history_asset_id_fkey" FOREIGN KEY (asset_id) REFERENCES assets(id)
|
||||
TABLE "user_assets" CONSTRAINT "user_assets_asset_id_fkey" FOREIGN KEY (asset_id) REFERENCES assets(id)
|
||||
|
||||
asset_pilot=# \q
|
||||
Reference in New Issue
Block a user