sum7/warehost
sum7
/
warehost
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
warehost/modul/host/models.go

116 lines
5.3 KiB
Go
Raw Normal View History

2016-09-01 22:19:39 +02:00
package host
import (
"github.com/jinzhu/gorm"
2016-10-18 20:26:17 +02:00
"dev.sum7.eu/sum7/warehost/lib/data"
2016-10-18 20:26:17 +02:00
"dev.sum7.eu/sum7/warehost/system"
2016-09-01 22:19:39 +02:00
)
2016-09-02 21:32:56 +02:00
// Profil struct
type Profil struct {
ID int64
2016-10-18 20:26:17 +02:00
LoginID int64 `sql:"type:bigint NOT NULL UNIQUE REFERENCES login(id) ON UPDATE CASCADE ON DELETE CASCADE;column:login" json:"-"`
Login *system.Login `gorm:"foreignkey:Login;" json:"login"`
Reseller bool `sql:"default:false;column:reseller" json:"reseller"`
2016-09-02 21:32:56 +02:00
}
// TableName of struct
func (Profil) TableName() string { return "host_profil" }
// Domain struct
type Domain struct {
ID int64
2016-10-18 20:26:17 +02:00
ProfilID int64 `sql:"type:bigint NOT NULL REFERENCES host_profil(id) ON UPDATE CASCADE ON DELETE CASCADE;column:profil" json:"-"`
Profil *Profil `gorm:"foreignkey:Profil;" json:"profil"`
FQDN string `sql:"type:varchar(255) NOT NULL UNIQUE;column:fqdn" json:"fqdn"`
Code string `sql:"type:varchar(255);column:code" json:"-"`
Active bool `sql:"default:false;column:active" json:"active"`
Mail bool `sql:"default:false;column:mail" json:"mail"`
Web bool `sql:"default:false;column:web" json:"web"`
2016-09-02 21:32:56 +02:00
}
// TableName of struct
func (Domain) TableName() string { return "host_domain" }
// Web struct
type Web struct {
ID int64
DomainID int64 `sql:"type:bigint NOT NULL REFERENCES host_domain(id) ON UPDATE CASCADE ON DELETE CASCADE;column:domain" json:"-"`
Domain *Domain `gorm:"foreignkey:Domain;unique_index:idx_host_domain_web" json:"domain"`
Subdomain string `sql:"type:varchar(255);column:subdomain" gorm:"unique_index:idx_host_domain_web" json:"subdomain"`
PHP bool `sql:"default:false;column:php" json:"php"`
SSL bool `sql:"default:true;column:ssl" json:"ssl"`
SSLRedirect bool `sql:"default:false;column:sslredirect" json:"sslredirect"`
Redirect string `sql:"type:varchar(255);column:redirect" json:"redirect"`
Proxy string `sql:"type:varchar(255);column:proxy" json:"proxy"`
FTPAccess []*FTPAccess `json:"ftpaccess"`
HTTPAccess []*HTTPAccess `json:"httpaccess"`
2016-09-02 21:32:56 +02:00
}
// TableName of struct
func (Web) TableName() string { return "host_web" }
2016-11-15 20:50:57 +01:00
// FTPAccess is a Object which user has access by ftp on the data of this website
type FTPAccess struct {
WebID int64 `sql:"type:bigint NOT NULL REFERENCES host_web(id) ON UPDATE CASCADE ON DELETE CASCADE;column:web" json:"-"`
Web *Web `gorm:"foreignkey:Web;unique_index:idx_host_domain_ftp_access" json:"web"`
LoginID int64 `sql:"type:bigint NOT NULL REFERENCES login(id) ON UPDATE CASCADE ON DELETE CASCADE;column:login" json:"-"`
Login *system.Login `gorm:"foreignkey:Login;unique_index:idx_host_domain_ftp_access" json:"login"`
}
// TableName of struct
func (FTPAccess) TableName() string { return "host_web_ftpaccess" }
// HTTPAccess is a Object which user has access by httpaccess on the data of this website
type HTTPAccess struct {
2016-11-15 20:50:57 +01:00
WebID int64 `sql:"type:bigint NOT NULL REFERENCES host_web(id) ON UPDATE CASCADE ON DELETE CASCADE;column:web" json:"-"`
Web *Web `gorm:"foreignkey:Web;unique_index:idx_host_domain_web_access" json:"web"`
LoginID int64 `sql:"type:bigint NOT NULL REFERENCES login(id) ON UPDATE CASCADE ON DELETE CASCADE;column:login" json:"-"`
Login *system.Login `gorm:"foreignkey:Login;unique_index:idx_host_domain_web_access" json:"login"`
}
// TableName of struct
func (HTTPAccess) TableName() string { return "host_web_httpaccess" }
2016-11-15 20:50:57 +01:00
2016-09-02 21:32:56 +02:00
// Mail struct
type Mail struct {
ID int64
DomainID int64 `sql:"type:bigint NOT NULL REFERENCES host_domain(id) ON UPDATE CASCADE ON DELETE CASCADE;column:domain" json:"-"`
Domain *Domain `gorm:"foreignkey:Domain;unique_index:idx_host_domain_mail" json:"domain"`
Name string `sql:"type:varchar(255);column:name" gorm:"unique_index:idx_host_domain_mail" json:"name"`
Forwards []*MailForward `json:"forwards"`
LoginID data.JsonNullInt64 `sql:"type:bigint NULL REFERENCES login(id) ON UPDATE CASCADE ON DELETE CASCADE;column:login" json:"login"`
2016-09-02 21:32:56 +02:00
}
// TableName of struct
func (Mail) TableName() string { return "host_mail" }
2016-11-15 20:50:57 +01:00
// MailForward is a Object on with address a copy of the mail should be send
type MailForward struct {
ID int64
MailID int64 `sql:"type:bigint NOT NULL REFERENCES host_mail(id) ON UPDATE CASCADE ON DELETE CASCADE;column:mail" json:"-"`
Mail *Mail `gorm:"foreignkey:Mail;unique_index:idx_host_domain_mail_forward" json:"mail"`
To string `sql:"type:varchar(255);column:to" gorm:"unique_index:idx_host_domain_mail_forward" json:"to"`
}
// TableName of struct
func (MailForward) TableName() string { return "host_mail_forward" }
2016-09-02 21:32:56 +02:00
// Database struct
type Database struct {
ID int64
2016-10-18 20:26:17 +02:00
ProfilID int64 `sql:"type:bigint NOT NULL REFERENCES host_profil(id) ON UPDATE CASCADE ON DELETE CASCADE;column:profil" json:"-"`
Profil *Profil `gorm:"foreignkey:Profil;" json:"profil"`
Password string `sql:"type:varchar(255);column:password" json:"password"`
Comment string `sql:"type:varchar(255);column:comment" json:"comment"`
2016-09-02 21:32:56 +02:00
}
// TableName of struct
func (Database) TableName() string { return "host_database" }
2016-09-01 22:19:39 +02:00
// SyncModels to verify the database schema
func SyncModels(dbconnection *gorm.DB) {
dbconnection.AutoMigrate(&Profil{}, &Domain{}, &Web{}, &HTTPAccess{}, &FTPAccess{}, &Mail{}, &MailForward{}, &Database{})
2016-09-01 22:19:39 +02:00
}