@@ -4,34 +4,53 @@ namespace Database
4
4
{
5
5
public class SqlSchema
6
6
{
7
- // TODO column names into constants
7
+ public const string TablePortfolios = "portfolios" ;
8
+ public const string PortfoliosId = "id" ;
9
+ public const string PortfoliosName = "name" ;
10
+ public const string PortfoliosDescription = "description" ;
11
+ public const string PortfoliosCurrencyCode = "currency_code" ;
12
+
13
+ public const string TablePortfolioEntries = "portfolio_entries" ;
14
+ public const string PortfolioEntriesId = "id" ;
15
+ public const string PortfolioEntriesSymbol = "symbol" ;
16
+ public const string PortfolioEntriesPortfolioId = "portfolio_id" ;
17
+
18
+ public const string TableMarketOrders = "market_orders" ;
19
+ public const string MarketOrdersId = "id" ;
20
+ public const string MarketOrdersFilledPrice = "filled_price" ;
21
+ public const string MarketOrdersFee = "fee" ;
22
+ public const string MarketOrdersSize = "size" ;
23
+ public const string MarketOrdersDate = "date" ;
24
+ public const string MarketOrdersBuy = "buy" ;
25
+ public const string MarketOrdersPortfolioEntryId = "portfolio_entry_id" ;
26
+
8
27
public static void Init ( SqlKataDatabase db )
9
28
{
10
- db . Get ( ) . Statement ( @"
29
+ db . Get ( ) . Statement ( $ @ "
11
30
12
- CREATE TABLE IF NOT EXISTS portfolios (
13
- id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
14
- name TEXT NOT NULL,
15
- description TEXT NOT NULL,
16
- currency_code INTEGER NOT NULL
31
+ CREATE TABLE IF NOT EXISTS { TablePortfolios } (
32
+ { PortfoliosId } INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
33
+ { PortfoliosName } TEXT NOT NULL,
34
+ { PortfoliosDescription } TEXT NOT NULL,
35
+ { PortfoliosCurrencyCode } INTEGER NOT NULL
17
36
);
18
37
19
- CREATE TABLE IF NOT EXISTS portfolio_entries (
20
- id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
21
- symbol TEXT NOT NULL,
22
- portfolio_id INTEGER NOT NULL,
23
- FOREIGN KEY(portfolio_id ) REFERENCES portfolios (id)
38
+ CREATE TABLE IF NOT EXISTS { TablePortfolioEntries } (
39
+ { PortfolioEntriesId } INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
40
+ { PortfolioEntriesSymbol } TEXT NOT NULL,
41
+ { PortfolioEntriesPortfolioId } INTEGER NOT NULL,
42
+ FOREIGN KEY({ PortfolioEntriesPortfolioId } ) REFERENCES { TablePortfolios } (id)
24
43
);
25
44
26
- CREATE TABLE IF NOT EXISTS market_orders (
27
- id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
28
- filled_price INTEGER NOT NULL,
29
- fee INTEGER NOT NULL,
30
- size INTEGER NOT NULL,
31
- date INTEGER NOT NULL,
32
- buy INTEGER NOT NULL,
33
- portfolio_entry_id INTEGER NOT NULL,
34
- FOREIGN KEY(portfolio_entry_id ) REFERENCES portfolio_entries (id)
45
+ CREATE TABLE IF NOT EXISTS { TableMarketOrders } (
46
+ { MarketOrdersId } INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
47
+ { MarketOrdersFilledPrice } INTEGER NOT NULL,
48
+ { MarketOrdersFee } INTEGER NOT NULL,
49
+ { MarketOrdersSize } INTEGER NOT NULL,
50
+ { MarketOrdersDate } INTEGER NOT NULL,
51
+ { MarketOrdersBuy } INTEGER NOT NULL,
52
+ { MarketOrdersPortfolioEntryId } INTEGER NOT NULL,
53
+ FOREIGN KEY({ MarketOrdersPortfolioEntryId } ) REFERENCES { TablePortfolioEntries } (id)
35
54
);
36
55
37
56
" ) ;
0 commit comments