add driversLicence model

This commit is contained in:
Alex
2024-09-29 21:16:58 +02:00
parent 41738753f0
commit 8a581da1d8
9 changed files with 135 additions and 16 deletions

View File

@@ -27,6 +27,8 @@ func Open(dbPath string, adminMail string) error {
&models.Membership{},
&models.Consent{},
&models.Verification{},
&models.DriversLicence{},
&models.LicenceCategory{},
&models.BankAccount{}); err != nil {
logger.Error.Fatalf("Couldn't create database: %v", err)
return err
@@ -51,6 +53,13 @@ func Open(dbPath string, adminMail string) error {
return err
}
categories := createLicenceCategories()
for _, model := range categories {
result := db.Create(&model)
if result.Error != nil {
return result.Error
}
}
admin, err := createAdmin(adminMail, createdModel.ID)
if err != nil {
return err
@@ -73,6 +82,28 @@ func createSubscriptionModels() []models.SubscriptionModel {
},
}
}
func createLicenceCategories() []models.LicenceCategory {
return []models.LicenceCategory{
{Category: "AM"},
{Category: "A1"},
{Category: "A2"},
{Category: "A"},
{Category: "B"},
{Category: "C1"},
{Category: "C"},
{Category: "D1"},
{Category: "D"},
{Category: "BE"},
{Category: "C1E"},
{Category: "CE"},
{Category: "D1E"},
{Category: "DE"},
{Category: "R"},
{Category: "L"},
}
}
// TODO: Landing page to create an admin
func createAdmin(userMail string, subscriptionModelID uint) (*models.User, error) {