|
|
@@ -8,11 +8,18 @@ import ( |
|
|
|
) |
|
|
|
|
|
|
|
type Bonus struct { |
|
|
|
gorm.Model |
|
|
|
Goal float64 `json:"goal"` |
|
|
|
Percent float64 `json:"percent"` |
|
|
|
RewardFundID uint `json:"rewardFundID"` |
|
|
|
} |
|
|
|
|
|
|
|
type Queue struct { |
|
|
|
gorm.Model |
|
|
|
Name string `json:"name"` |
|
|
|
Funds []RewardFund `json:"funds"` |
|
|
|
} |
|
|
|
|
|
|
|
type RewardFund struct { |
|
|
|
gorm.Model |
|
|
|
Asset string `json:"asset"` |
|
|
@@ -26,9 +33,13 @@ type RewardFund struct { |
|
|
|
Contributions []Contribution `json:"contributions"` |
|
|
|
Title string `gorm:"type:varchar(50)" json:"title"` |
|
|
|
Description string `gorm:"type:text" json:"description"` |
|
|
|
QueueID uint `json:"queueID"` |
|
|
|
Bonuses []Bonus `json:"bonuses"` |
|
|
|
} |
|
|
|
|
|
|
|
type QueueRewardFund struct { |
|
|
|
} |
|
|
|
|
|
|
|
type Contribution struct { |
|
|
|
gorm.Model |
|
|
|
Wallet string `json:"wallet"` |
|
|
@@ -70,7 +81,10 @@ func InitializeDatabase() { |
|
|
|
viper.GetInt("database.port"), |
|
|
|
viper.GetString("database.ssl")) |
|
|
|
Db, err = gorm.Open(postgres.Open(dcs), &gorm.Config{}) |
|
|
|
err = Db.AutoMigrate(User{}, RewardFund{}, Contribution{}, Bonus{}) |
|
|
|
if err != nil { |
|
|
|
panic("Could not open database") |
|
|
|
} |
|
|
|
err = Db.AutoMigrate(User{}, Queue{}, RewardFund{}, Contribution{}, Bonus{}) |
|
|
|
if err != nil { |
|
|
|
panic("Could not migrate database") |
|
|
|
} |
|
|
|