merge develop

Signed-off-by: Ronni Skansing <rskansing@gmail.com>
This commit is contained in:
Ronni Skansing
2026-06-07 16:49:23 +02:00
754 changed files with 251084 additions and 35037 deletions
+2
View File
@@ -26,6 +26,8 @@ type Attachment struct {
Description string `gorm:";"`
Filename string `gorm:"not null;index"`
EmbeddedContent bool `gorm:"not null;default:false;index"`
// SendAsCalendar sends ics files as a calendar invitation
SendAsCalendar bool `gorm:"not null;default:false;index"`
}
func (Attachment) TableName() string {
+34
View File
@@ -0,0 +1,34 @@
package database
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
const (
REMOTE_BROWSER_TABLE = "remote_browsers"
)
// RemoteBrowser is a gorm data model for saved remote browser scripts.
type RemoteBrowser struct {
ID *uuid.UUID `gorm:"primary_key;not null;unique;type:uuid"`
CreatedAt *time.Time `gorm:"not null;index;"`
UpdatedAt *time.Time `gorm:"not null;index"`
CompanyID *uuid.UUID `gorm:"index;uniqueIndex:idx_remote_browsers_unique_name_and_company_id;type:uuid"`
Name string `gorm:"not null;index;uniqueIndex:idx_remote_browsers_unique_name_and_company_id;"`
Description string `gorm:"type:text"`
Script string `gorm:"type:text;not null;"`
Config string `gorm:"type:text;not null;default:'{}'"`
Company *Company
}
func (e *RemoteBrowser) Migrate(db *gorm.DB) error {
return UniqueIndexNameAndNullCompanyID(db, "remote_browsers")
}
func (RemoteBrowser) TableName() string {
return REMOTE_BROWSER_TABLE
}
+33
View File
@@ -0,0 +1,33 @@
package database
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
const (
REPORT_TEMPLATE_TABLE = "report_templates"
)
// ReportTemplate is a gorm data model
type ReportTemplate struct {
ID *uuid.UUID `gorm:"primary_key;not null;unique;type:uuid"`
CreatedAt *time.Time `gorm:"not null;index;"`
UpdatedAt *time.Time `gorm:"not null;index"`
CompanyID *uuid.UUID `gorm:"uniqueIndex;type:uuid"`
Content string `gorm:"not null;type:text"`
Company *Company
}
func (e *ReportTemplate) Migrate(db *gorm.DB) error {
// enforce at most one global template (company_id IS NULL)
idx := `CREATE UNIQUE INDEX IF NOT EXISTS idx_report_templates_null_company_id ON report_templates ((company_id IS NULL)) WHERE (company_id IS NULL)`
return db.Exec(idx).Error
}
func (ReportTemplate) TableName() string {
return REPORT_TEMPLATE_TABLE
}