models

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package models contains the database model definitions. These models map directly to the SQLite database tables.

Index

Constants

View Source
const (
	DeviceStatusPending  = "PENDING"
	DeviceStatusApproved = "APPROVED"
	DeviceStatusRevoked  = "REVOKED"
)

DeviceStatus represents the current status of a device.

View Source
const (
	DevicePermissionsReadOnly = "READ_ONLY"
	DevicePermissionsOperator = "OPERATOR"
	DevicePermissionsAdmin    = "ADMIN"
)

DevicePermissions represents the permission level for a device.

View Source
const (
	GroupRoleMember     = "MEMBER"
	GroupRoleGroupAdmin = "GROUP_ADMIN"
)

Group member role constants.

View Source
const (
	InvitationStatusPending  = "PENDING"
	InvitationStatusAccepted = "ACCEPTED"
	InvitationStatusDeclined = "DECLINED"
	InvitationStatusExpired  = "EXPIRED"
)

Group invitation status constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthSetting added in v0.2.31

type AuthSetting struct {
	ID        string    `gorm:"column:id;primaryKey"`
	Key       string    `gorm:"column:key;uniqueIndex"`
	Value     string    `gorm:"column:value"`
	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"`
}

AuthSetting stores global authentication configuration settings. Table: auth_settings

func (AuthSetting) TableName added in v0.2.31

func (AuthSetting) TableName() string

type ChannelDefinition

type ChannelDefinition struct {
	ID           string `gorm:"column:id;primaryKey"`
	Name         string `gorm:"column:name"`
	Type         string `gorm:"column:type"`
	Offset       int    `gorm:"column:offset"`
	MinValue     int    `gorm:"column:min_value;default:0"`
	MaxValue     int    `gorm:"column:max_value;default:255"`
	DefaultValue int    `gorm:"column:default_value;default:0"`
	FadeBehavior string `gorm:"column:fade_behavior;default:FADE"` // FadeBehavior enum: FADE, SNAP, SNAP_END
	IsDiscrete   bool   `gorm:"column:is_discrete;default:false"`  // True if channel has multiple discrete DMX ranges
	DefinitionID string `gorm:"column:definition_id;index"`
}

ChannelDefinition represents a channel within a fixture definition. Table: channel_definitions

func (ChannelDefinition) TableName

func (ChannelDefinition) TableName() string

type ChannelValue added in v0.2.0

type ChannelValue struct {
	Offset int `json:"offset"`
	Value  int `json:"value"`
}

ChannelValue represents a single channel's value in a look

type Cue

type Cue struct {
	ID          string    `gorm:"column:id;primaryKey"`
	Name        string    `gorm:"column:name"`
	CueNumber   float64   `gorm:"column:cue_number"`
	CueListID   string    `gorm:"column:cue_list_id;index"`
	LookID      string    `gorm:"column:look_id;index"`
	FadeInTime  float64   `gorm:"column:fade_in_time;default:0"`
	FadeOutTime float64   `gorm:"column:fade_out_time;default:0"`
	FollowTime  *float64  `gorm:"column:follow_time"`
	EasingType  *string   `gorm:"column:easing_type"`
	Notes       *string   `gorm:"column:notes"`
	Skip        bool      `gorm:"column:skip;default:false"`
	CreatedAt   time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt   time.Time `gorm:"column:updated_at;autoUpdateTime"`

	// Relations
	Look    *Look       `gorm:"foreignKey:LookID"`
	Effects []CueEffect `gorm:"foreignKey:CueID"`
}

Cue represents a lighting cue within a cue list. Table: cues

func (Cue) TableName

func (Cue) TableName() string

type CueEffect added in v0.2.30

type CueEffect struct {
	ID       string  `gorm:"column:id;primaryKey"`
	CueID    string  `gorm:"column:cue_id;index"`
	Cue      *Cue    `gorm:"foreignKey:CueID"`
	EffectID string  `gorm:"column:effect_id;index"`
	Effect   *Effect `gorm:"foreignKey:EffectID"`

	Intensity   float64 `gorm:"column:intensity;default:100.0"` // 0-100
	Speed       float64 `gorm:"column:speed;default:1.0"`       // Frequency multiplier
	OnCueChange *string `gorm:"column:on_cue_change"`           // Override effect's default behavior

	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
}

CueEffect links effects to cues with runtime parameters. Table: cue_effects

func (CueEffect) TableName added in v0.2.30

func (CueEffect) TableName() string

type CueList

type CueList struct {
	ID          string    `gorm:"column:id;primaryKey"`
	Name        string    `gorm:"column:name"`
	Description *string   `gorm:"column:description"`
	Loop        bool      `gorm:"column:loop;default:false"`
	ProjectID   string    `gorm:"column:project_id;index"`
	CreatedAt   time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt   time.Time `gorm:"column:updated_at;autoUpdateTime"`

	// Relations
	Cues []Cue `gorm:"foreignKey:CueListID"`
}

CueList represents a cue list (sequence of cues). Table: cue_lists

func (CueList) TableName

func (CueList) TableName() string

type Device added in v0.2.31

type Device struct {
	ID                         string     `gorm:"column:id;primaryKey"`
	Name                       string     `gorm:"column:name"`
	Fingerprint                string     `gorm:"column:fingerprint;uniqueIndex"`
	FingerprintComponents      *string    `gorm:"column:fingerprint_components"`        // JSON
	Status                     string     `gorm:"column:status;default:PENDING;index"`  // PENDING, APPROVED, REVOKED
	Permissions                string     `gorm:"column:permissions;default:READ_ONLY"` // READ_ONLY, OPERATOR, ADMIN
	IsAuthorized               bool       `gorm:"column:is_authorized;default:false"`   // Legacy field - kept for backward compatibility. Use Status field for authoritative state.
	AuthorizationCode          *string    `gorm:"column:authorization_code"`
	AuthorizationCodeExpiresAt *time.Time `gorm:"column:authorization_code_expires_at"`
	DefaultUserID              *string    `gorm:"column:default_user_id;index"`
	DefaultRole                string     `gorm:"column:default_role;default:PLAYER"`
	LastSeenAt                 *time.Time `gorm:"column:last_seen_at"`
	LastIPAddress              *string    `gorm:"column:last_ip_address"`
	CreatedAt                  time.Time  `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt                  time.Time  `gorm:"column:updated_at;autoUpdateTime"`
	ApprovedAt                 *time.Time `gorm:"column:approved_at"`
	ApprovedByID               *string    `gorm:"column:approved_by;index"`

	// Relations
	DefaultUser *User `gorm:"foreignKey:DefaultUserID"`
	ApprovedBy  *User `gorm:"foreignKey:ApprovedByID"`
}

Device represents a pre-authorized device for device-based authentication. Table: devices

func (Device) TableName added in v0.2.31

func (Device) TableName() string

type DeviceGroupMember added in v0.2.31

type DeviceGroupMember struct {
	ID        string    `gorm:"column:id;primaryKey"`
	DeviceID  string    `gorm:"column:device_id;uniqueIndex:idx_device_group_member"`
	GroupID   string    `gorm:"column:group_id;uniqueIndex:idx_device_group_member"`
	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`

	// Relations
	Device *Device    `gorm:"foreignKey:DeviceID"`
	Group  *UserGroup `gorm:"foreignKey:GroupID"`
}

DeviceGroupMember represents a device's membership in a group (many-to-many). A device can belong to multiple groups (e.g., a shared iPad used by multiple organizations). Table: device_group_members

func (DeviceGroupMember) TableName added in v0.2.31

func (DeviceGroupMember) TableName() string

type Effect added in v0.2.30

type Effect struct {
	ID          string  `gorm:"column:id;primaryKey"`
	Name        string  `gorm:"column:name"`
	Description *string `gorm:"column:description"`
	ProjectID   string  `gorm:"column:project_id;index"`
	Project     *Project

	EffectType      string   `gorm:"column:effect_type;default:WAVEFORM"`      // WAVEFORM, CROSSFADE, STATIC, MASTER
	PriorityBand    string   `gorm:"column:priority_band;default:USER"`        // BASE, USER, CUE, SYSTEM
	PrioritySub     int      `gorm:"column:priority_sub;default:50"`           // 0-100
	CompositionMode string   `gorm:"column:composition_mode;default:OVERRIDE"` // OVERRIDE, ADDITIVE, MULTIPLY
	OnCueChange     string   `gorm:"column:on_cue_change;default:FADE_OUT"`    // FADE_OUT, PERSIST, SNAP_OFF, CROSSFADE_PARAMS
	FadeDuration    *float64 `gorm:"column:fade_duration"`

	// For WAVEFORM effects
	EasingType  *string `gorm:"column:easing_type"`
	Waveform    *string `gorm:"column:waveform"`                 // SINE, COSINE, SQUARE, SAWTOOTH, TRIANGLE, RANDOM
	Frequency   float64 `gorm:"column:frequency;default:1.0"`    // Hz
	Amplitude   float64 `gorm:"column:amplitude;default:100.0"`  // Percentage
	Offset      float64 `gorm:"column:offset;default:50.0"`      // Percentage (center value)
	PhaseOffset float64 `gorm:"column:phase_offset;default:0.0"` // Degrees

	// For MASTER effects
	MasterValue *float64 `gorm:"column:master_value"` // 0.0-1.0

	// Relations
	Fixtures []EffectFixture `gorm:"foreignKey:EffectID;constraint:OnDelete:CASCADE"`

	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"`
}

Effect represents an FX Engine effect definition. Effects can be WAVEFORM (oscillating), CROSSFADE, STATIC, or MASTER types. Table: effects

func (Effect) TableName added in v0.2.30

func (Effect) TableName() string

type EffectChannel added in v0.2.30

type EffectChannel struct {
	ID              string `gorm:"column:id;primaryKey"`
	EffectFixtureID string `gorm:"column:effect_fixture_id;index"`

	ChannelOffset *int    `gorm:"column:channel_offset"` // Which channel (offset from fixture start)
	ChannelType   *string `gorm:"column:channel_type"`   // INTENSITY, COLOR, PAN, TILT, etc.

	AmplitudeScale *float64 `gorm:"column:amplitude_scale"` // Per-channel amplitude
	FrequencyScale *float64 `gorm:"column:frequency_scale"` // Per-channel frequency multiplier

	// Min/Max define oscillation range (0-100%). When set, internally convert to offset/amplitude:
	// offset = (min + max) / 2, amplitude = (max - min) / 2
	MinValue *float64 `gorm:"column:min_value"` // Minimum oscillation value (0-100%)
	MaxValue *float64 `gorm:"column:max_value"` // Maximum oscillation value (0-100%)

	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
}

EffectChannel defines per-channel overrides within an EffectFixture. Table: effect_channels

func (EffectChannel) TableName added in v0.2.30

func (EffectChannel) TableName() string

type EffectFixture added in v0.2.30

type EffectFixture struct {
	ID        string           `gorm:"column:id;primaryKey"`
	EffectID  string           `gorm:"column:effect_id;index"`
	FixtureID string           `gorm:"column:fixture_id;index"`
	Fixture   *FixtureInstance `gorm:"foreignKey:FixtureID"`

	PhaseOffset    *float64 `gorm:"column:phase_offset"`    // Per-fixture phase offset
	AmplitudeScale *float64 `gorm:"column:amplitude_scale"` // Per-fixture amplitude multiplier
	EffectOrder    *int     `gorm:"column:effect_order"`    // Order in the effect

	// Relations
	Channels []EffectChannel `gorm:"foreignKey:EffectFixtureID;constraint:OnDelete:CASCADE"`

	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
}

EffectFixture links effects to fixtures with per-fixture settings. Table: effect_fixtures

func (EffectFixture) TableName added in v0.2.30

func (EffectFixture) TableName() string

type FixtureDefinition

type FixtureDefinition struct {
	ID           string    `gorm:"column:id;primaryKey"`
	Manufacturer string    `gorm:"column:manufacturer"`
	Model        string    `gorm:"column:model"`
	Type         string    `gorm:"column:type"`
	IsBuiltIn    bool      `gorm:"column:is_built_in;default:false"`
	RefID        string    `gorm:"column:ref_id;not null;default:''"` // global unique identifier for round-trip definition matching
	CreatedAt    time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt    time.Time `gorm:"column:updated_at;autoUpdateTime"`

	// OFL tracking fields for change detection
	OFLSourceHash *string `gorm:"column:ofl_source_hash"` // SHA256 of the original OFL JSON
	OFLVersion    *string `gorm:"column:ofl_version"`     // OFL commit/version when imported

	// Relations
	Channels []ChannelDefinition `gorm:"foreignKey:DefinitionID"`
	Modes    []FixtureMode       `gorm:"foreignKey:DefinitionID"`
}

FixtureDefinition represents a fixture type definition. Table: fixture_definitions

func (FixtureDefinition) TableName

func (FixtureDefinition) TableName() string

type FixtureGroup added in v0.3.0

type FixtureGroup struct {
	ID           string  `gorm:"column:id;primaryKey"`
	ProjectID    string  `gorm:"column:project_id;index;not null"`
	Name         string  `gorm:"column:name;not null"`
	Description  *string `gorm:"column:description"`
	EosNumber    *int    `gorm:"column:eos_number"` // nullable; stable across exports once assigned
	RefID        string  `gorm:"column:ref_id;not null;default:''"`
	ProjectOrder *int    `gorm:"column:project_order"`

	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"`

	Members []FixtureGroupMember `gorm:"foreignKey:GroupID;constraint:OnDelete:CASCADE"`
}

FixtureGroup represents a named collection of fixture instances within a project. Surfaces in EOS ASCII as $Group blocks; each LacyLights group has an optional EosNumber that the writer uses for stable group numbering. Table: fixture_groups

func (FixtureGroup) TableName added in v0.3.0

func (FixtureGroup) TableName() string

type FixtureGroupMember added in v0.3.0

type FixtureGroupMember struct {
	GroupID    string `gorm:"column:group_id;primaryKey"`
	FixtureID  string `gorm:"column:fixture_id;primaryKey"`
	OrderIndex int    `gorm:"column:order_index;not null"`
}

FixtureGroupMember is a junction row tying a FixtureGroup to a FixtureInstance. Composite PK (group_id, fixture_id) ensures one row per membership; the OrderIndex column gives stable iteration. Table: fixture_group_members

func (FixtureGroupMember) TableName added in v0.3.0

func (FixtureGroupMember) TableName() string

type FixtureInstance

type FixtureInstance struct {
	ID           string  `gorm:"column:id;primaryKey"`
	Name         string  `gorm:"column:name"`
	Description  *string `gorm:"column:description"`
	DefinitionID string  `gorm:"column:definition_id;index"`
	Manufacturer *string `gorm:"column:manufacturer"` // Denormalized
	Model        *string `gorm:"column:model"`        // Denormalized
	Type         *string `gorm:"column:type"`         // Denormalized
	ModeName     *string `gorm:"column:mode_name"`
	ChannelCount *int    `gorm:"column:channel_count"`
	ProjectID    string  `gorm:"column:project_id;index"`
	Universe     int     `gorm:"column:universe"`
	StartChannel int     `gorm:"column:start_channel"`
	Tags         *string `gorm:"column:tags;default:[]"`            // JSON array
	RefID        string  `gorm:"column:ref_id;not null;default:''"` // stable cross-roundtrip identifier; project-scoped unique via runtime index

	ProjectOrder   *int     `gorm:"column:project_order"`
	LayoutX        *float64 `gorm:"column:layout_x"`
	LayoutY        *float64 `gorm:"column:layout_y"`
	LayoutRotation *float64 `gorm:"column:layout_rotation"`

	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"`

	// Relations
	Definition *FixtureDefinition `gorm:"foreignKey:DefinitionID"`
	Channels   []InstanceChannel  `gorm:"foreignKey:FixtureID"`
}

FixtureInstance represents a physical fixture instance in a project. Table: fixture_instances

func (FixtureInstance) TableName

func (FixtureInstance) TableName() string

type FixtureMode

type FixtureMode struct {
	ID           string  `gorm:"column:id;primaryKey"`
	Name         string  `gorm:"column:name"`
	ShortName    *string `gorm:"column:short_name"`
	ChannelCount int     `gorm:"column:channel_count"`
	DefinitionID string  `gorm:"column:definition_id;index"`

	// Relations
	ModeChannels []ModeChannel `gorm:"foreignKey:ModeID"`
}

FixtureMode represents a mode within a fixture definition. Table: fixture_modes

func (FixtureMode) TableName

func (FixtureMode) TableName() string

type FixtureValue

type FixtureValue struct {
	ID        string `gorm:"column:id;primaryKey"`
	LookID    string `gorm:"column:look_id;index"`
	FixtureID string `gorm:"column:fixture_id;index"`
	Channels  string `gorm:"column:channels;default:[]"` // JSON array of ChannelValue
	LookOrder *int   `gorm:"column:look_order"`
}

FixtureValue represents fixture channel values within a look. Table: fixture_values

func (FixtureValue) TableName

func (FixtureValue) TableName() string

type GroupInvitation added in v0.2.31

type GroupInvitation struct {
	ID          string     `gorm:"column:id;primaryKey"`
	GroupID     string     `gorm:"column:group_id;index"`
	Email       string     `gorm:"column:email;index"`
	InvitedByID string     `gorm:"column:invited_by_id"`
	Role        string     `gorm:"column:role;default:MEMBER"`    // MEMBER, GROUP_ADMIN
	Status      string     `gorm:"column:status;default:PENDING"` // PENDING, ACCEPTED, DECLINED, EXPIRED
	ExpiresAt   time.Time  `gorm:"column:expires_at"`
	AcceptedAt  *time.Time `gorm:"column:accepted_at"`
	CreatedAt   time.Time  `gorm:"column:created_at;autoCreateTime"`

	// Relations
	Group     *UserGroup `gorm:"foreignKey:GroupID"`
	InvitedBy *User      `gorm:"foreignKey:InvitedByID"`
}

GroupInvitation represents an invitation for a user to join a group. Table: group_invitations

func (GroupInvitation) TableName added in v0.2.31

func (GroupInvitation) TableName() string

type InstanceChannel

type InstanceChannel struct {
	ID           string `gorm:"column:id;primaryKey"`
	FixtureID    string `gorm:"column:fixture_id;index"`
	Offset       int    `gorm:"column:offset"`
	Name         string `gorm:"column:name"`
	Type         string `gorm:"column:type"`
	MinValue     int    `gorm:"column:min_value;default:0"`
	MaxValue     int    `gorm:"column:max_value;default:255"`
	DefaultValue int    `gorm:"column:default_value;default:0"`
	FadeBehavior string `gorm:"column:fade_behavior;default:FADE"` // FadeBehavior enum: FADE, SNAP, SNAP_END
	IsDiscrete   bool   `gorm:"column:is_discrete;default:false"`  // True if channel has multiple discrete DMX ranges
}

InstanceChannel represents a channel on a fixture instance. Table: instance_channels

func (InstanceChannel) TableName

func (InstanceChannel) TableName() string

type Look added in v0.2.30

type Look struct {
	ID          string    `gorm:"column:id;primaryKey"`
	Name        string    `gorm:"column:name"`
	Description *string   `gorm:"column:description"`
	ProjectID   string    `gorm:"column:project_id;index"`
	RefID       string    `gorm:"column:ref_id;not null;default:''"` // project-scoped stable identifier for sidecar references
	CreatedAt   time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt   time.Time `gorm:"column:updated_at;autoUpdateTime"`

	// Relations
	FixtureValues []FixtureValue `gorm:"foreignKey:LookID"`
}

Look represents a lighting look (formerly known as "scene"). A look captures a snapshot of fixture channel values that can be recalled. Table: looks

func (Look) TableName added in v0.2.30

func (Look) TableName() string

type LookBoard added in v0.2.30

type LookBoard struct {
	ID              string    `gorm:"column:id;primaryKey"`
	Name            string    `gorm:"column:name"`
	Description     *string   `gorm:"column:description"`
	ProjectID       string    `gorm:"column:project_id;index"`
	RefID           string    `gorm:"column:ref_id;not null;default:''"` // project-scoped stable identifier for sidecar references
	DefaultFadeTime float64   `gorm:"column:default_fade_time;default:3.0"`
	GridSize        *int      `gorm:"column:grid_size;default:50"`
	CanvasWidth     int       `gorm:"column:canvas_width;default:2000"`
	CanvasHeight    int       `gorm:"column:canvas_height;default:2000"`
	CreatedAt       time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt       time.Time `gorm:"column:updated_at;autoUpdateTime"`

	// Relations
	Buttons []LookBoardButton `gorm:"foreignKey:LookBoardID"`
}

LookBoard represents a look board for organizing looks (formerly SceneBoard). Table: look_boards

func (LookBoard) TableName added in v0.2.30

func (LookBoard) TableName() string

type LookBoardButton added in v0.2.30

type LookBoardButton struct {
	ID          string    `gorm:"column:id;primaryKey"`
	LookBoardID string    `gorm:"column:look_board_id;index"`
	LookID      string    `gorm:"column:look_id;index"`
	LayoutX     int       `gorm:"column:layout_x"`
	LayoutY     int       `gorm:"column:layout_y"`
	Width       *int      `gorm:"column:width;default:200"`
	Height      *int      `gorm:"column:height;default:120"`
	Color       *string   `gorm:"column:color"`
	Label       *string   `gorm:"column:label"`
	CreatedAt   time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt   time.Time `gorm:"column:updated_at;autoUpdateTime"`

	// Relations
	Look *Look `gorm:"foreignKey:LookID"`
}

LookBoardButton represents a button on a look board (formerly SceneBoardButton). Table: look_board_buttons

func (LookBoardButton) TableName added in v0.2.30

func (LookBoardButton) TableName() string

type ModeChannel

type ModeChannel struct {
	ID        string `gorm:"column:id;primaryKey"`
	ModeID    string `gorm:"column:mode_id;index"`
	ChannelID string `gorm:"column:channel_id;index"`
	Offset    int    `gorm:"column:offset"`
}

ModeChannel represents the mapping of channels to modes. Table: mode_channels

func (ModeChannel) TableName

func (ModeChannel) TableName() string

type OFLImportMeta added in v0.2.0

type OFLImportMeta struct {
	ID                string    `gorm:"column:id;primaryKey"`
	OFLVersion        string    `gorm:"column:ofl_version"`        // Commit SHA or version tag
	StartedAt         time.Time `gorm:"column:started_at"`         // When import started
	CompletedAt       time.Time `gorm:"column:completed_at"`       // When import completed
	TotalFixtures     int       `gorm:"column:total_fixtures"`     // Total fixtures in OFL
	SuccessfulImports int       `gorm:"column:successful_imports"` // Successfully imported
	FailedImports     int       `gorm:"column:failed_imports"`     // Failed to import
	SkippedDuplicates int       `gorm:"column:skipped_duplicates"` // Already existed
	UpdatedFixtures   int       `gorm:"column:updated_fixtures"`   // Updated existing fixtures
	UsedBundledData   bool      `gorm:"column:used_bundled_data"`  // True if imported from bundle
	ErrorMessage      *string   `gorm:"column:error_message"`      // Error if import failed
}

OFLImportMeta tracks the history of OFL imports. Table: ofl_import_meta

func (OFLImportMeta) TableName added in v0.2.0

func (OFLImportMeta) TableName() string

type Operation added in v0.2.30

type Operation struct {
	ID            string    `gorm:"column:id;primaryKey"`
	ProjectID     string    `gorm:"column:project_id;index"`
	OperationType string    `gorm:"column:operation_type"` // CREATE, UPDATE, DELETE, BULK
	EntityType    string    `gorm:"column:entity_type"`    // Look, FixtureInstance, Cue, etc.
	EntityID      string    `gorm:"column:entity_id"`
	Description   string    `gorm:"column:description"`
	PreviousState string    `gorm:"column:previous_state"` // JSON snapshot before
	NewState      string    `gorm:"column:new_state"`      // JSON snapshot after
	RelatedIDs    *string   `gorm:"column:related_ids"`    // JSON array for bulk ops
	Sequence      int       `gorm:"column:sequence;index"`
	CreatedAt     time.Time `gorm:"column:created_at;autoCreateTime"`
}

Operation represents a recorded operation for undo/redo functionality. Each operation captures the state before and after a mutation, enabling reversal. Table: operations

func (Operation) TableName added in v0.2.30

func (Operation) TableName() string

type OperationPointer added in v0.2.30

type OperationPointer struct {
	ID              string    `gorm:"column:id;primaryKey"`
	ProjectID       string    `gorm:"column:project_id;uniqueIndex"`
	CurrentSequence int       `gorm:"column:current_sequence;default:0"`
	MaxSequence     int       `gorm:"column:max_sequence;default:0"`
	UpdatedAt       time.Time `gorm:"column:updated_at;autoUpdateTime"`
}

OperationPointer tracks the current position in each project's undo/redo stack. The CurrentSequence indicates the most recently applied operation. Operations with sequence > CurrentSequence are "redo" candidates. Table: operation_pointers

func (OperationPointer) TableName added in v0.2.30

func (OperationPointer) TableName() string

type PreviewSession

type PreviewSession struct {
	ID        string    `gorm:"column:id;primaryKey"`
	ProjectID string    `gorm:"column:project_id;index"`
	UserID    string    `gorm:"column:user_id;index"`
	IsActive  bool      `gorm:"column:is_active;default:true"`
	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"`
}

PreviewSession represents a preview session. Table: preview_sessions

func (PreviewSession) TableName

func (PreviewSession) TableName() string

type Project

type Project struct {
	ID          string    `gorm:"column:id;primaryKey"`
	Name        string    `gorm:"column:name"`
	Description *string   `gorm:"column:description"`
	GroupID     *string   `gorm:"column:group_id;index"` // nullable for auth-off compatibility
	CreatedAt   time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt   time.Time `gorm:"column:updated_at;autoUpdateTime"`

	// Soft delete support - nil means not deleted
	DeletedAt *time.Time `gorm:"column:deleted_at;index"`

	// 2D Layout Canvas Configuration (for fixture layout editor)
	LayoutCanvasWidth  int `gorm:"column:layout_canvas_width;default:2000"`
	LayoutCanvasHeight int `gorm:"column:layout_canvas_height;default:2000"`

	// Relations (loaded separately)
	Group      *UserGroup        `gorm:"foreignKey:GroupID"`
	Fixtures   []FixtureInstance `gorm:"foreignKey:ProjectID"`
	Looks      []Look            `gorm:"foreignKey:ProjectID"`
	CueLists   []CueList         `gorm:"foreignKey:ProjectID"`
	LookBoards []LookBoard       `gorm:"foreignKey:ProjectID"`
	Effects    []Effect          `gorm:"foreignKey:ProjectID"`
}

Project represents a lighting project. Table: projects

func (Project) TableName

func (Project) TableName() string

type ProjectUser

type ProjectUser struct {
	ID        string    `gorm:"column:id;primaryKey"`
	UserID    string    `gorm:"column:user_id;index"`
	ProjectID string    `gorm:"column:project_id;index"`
	Role      string    `gorm:"column:role;default:VIEWER"`
	JoinedAt  time.Time `gorm:"column:joined_at;autoCreateTime"`
}

ProjectUser represents the many-to-many relationship between users and projects. Table: project_users

func (ProjectUser) TableName

func (ProjectUser) TableName() string

type Session added in v0.2.31

type Session struct {
	ID             string    `gorm:"column:id;primaryKey"`
	UserID         string    `gorm:"column:user_id;index"`
	TokenHash      string    `gorm:"column:token_hash;uniqueIndex"`
	DeviceID       *string   `gorm:"column:device_id;index"`
	IPAddress      *string   `gorm:"column:ip_address"`
	UserAgent      *string   `gorm:"column:user_agent"`
	ExpiresAt      time.Time `gorm:"column:expires_at"`
	LastActivityAt time.Time `gorm:"column:last_activity_at"`
	CreatedAt      time.Time `gorm:"column:created_at;autoCreateTime"`

	// Relations
	User   *User   `gorm:"foreignKey:UserID"`
	Device *Device `gorm:"foreignKey:DeviceID"`
}

Session represents an active user session. Table: sessions

func (Session) TableName added in v0.2.31

func (Session) TableName() string

type Setting

type Setting struct {
	ID        string    `gorm:"column:id;primaryKey"`
	Key       string    `gorm:"column:key;uniqueIndex"`
	Value     string    `gorm:"column:value"`
	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"`
}

Setting represents a system setting. Table: settings

func (Setting) TableName

func (Setting) TableName() string

type User

type User struct {
	ID            string     `gorm:"column:id;primaryKey"`
	Email         string     `gorm:"column:email;uniqueIndex"`
	Name          *string    `gorm:"column:name"`
	Phone         *string    `gorm:"column:phone"`
	Role          string     `gorm:"column:role;default:USER"`
	EmailVerified bool       `gorm:"column:email_verified;default:false"`
	PhoneVerified bool       `gorm:"column:phone_verified;default:false"`
	IsActive      bool       `gorm:"column:is_active;default:true"`
	LastLoginAt   *time.Time `gorm:"column:last_login_at"`
	CreatedAt     time.Time  `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt     time.Time  `gorm:"column:updated_at;autoUpdateTime"`
}

User represents a user in the system. Table: users

func (User) TableName

func (User) TableName() string

type UserCredential added in v0.2.31

type UserCredential struct {
	ID                string     `gorm:"column:id;primaryKey"`
	UserID            string     `gorm:"column:user_id;uniqueIndex"`
	PasswordHash      string     `gorm:"column:password_hash"`
	PasswordUpdatedAt time.Time  `gorm:"column:password_updated_at"`
	FailedAttempts    int        `gorm:"column:failed_attempts;default:0"`
	LockedUntil       *time.Time `gorm:"column:locked_until"`
	CreatedAt         time.Time  `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt         time.Time  `gorm:"column:updated_at;autoUpdateTime"`

	// Relations
	User *User `gorm:"foreignKey:UserID"`
}

UserCredential stores password credentials for a user. Table: user_credentials

func (UserCredential) TableName added in v0.2.31

func (UserCredential) TableName() string

type UserGroup added in v0.2.31

type UserGroup struct {
	ID          string    `gorm:"column:id;primaryKey"`
	Name        string    `gorm:"column:name;uniqueIndex"`
	Description *string   `gorm:"column:description"`
	Permissions *string   `gorm:"column:permissions"` // JSON array of permission strings
	IsPersonal  bool      `gorm:"column:is_personal;default:false"`
	OwnerID     *string   `gorm:"column:owner_id;index"`
	CreatedAt   time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt   time.Time `gorm:"column:updated_at;autoUpdateTime"`

	// Relations
	Members []UserGroupMember `gorm:"foreignKey:GroupID"`
	Owner   *User             `gorm:"foreignKey:OwnerID"`
}

UserGroup represents a permission group for users. Table: user_groups

func (UserGroup) TableName added in v0.2.31

func (UserGroup) TableName() string

type UserGroupMember added in v0.2.31

type UserGroupMember struct {
	ID        string    `gorm:"column:id;primaryKey"`
	UserID    string    `gorm:"column:user_id;uniqueIndex:idx_user_group_member"`
	GroupID   string    `gorm:"column:group_id;uniqueIndex:idx_user_group_member"`
	Role      string    `gorm:"column:role;default:MEMBER"` // MEMBER, GROUP_ADMIN
	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`

	// Relations
	User  *User      `gorm:"foreignKey:UserID"`
	Group *UserGroup `gorm:"foreignKey:GroupID"`
}

UserGroupMember represents a user's membership in a group. Table: user_group_members

func (UserGroupMember) TableName added in v0.2.31

func (UserGroupMember) TableName() string

type UserOAuth added in v0.2.31

type UserOAuth struct {
	ID             string    `gorm:"column:id;primaryKey"`
	UserID         string    `gorm:"column:user_id;index"`
	Provider       string    `gorm:"column:provider"`
	ProviderUserID string    `gorm:"column:provider_user_id"`
	Email          *string   `gorm:"column:email"`
	RefreshToken   *string   `gorm:"column:refresh_token"`
	CreatedAt      time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt      time.Time `gorm:"column:updated_at;autoUpdateTime"`

	// Relations
	User *User `gorm:"foreignKey:UserID"`
}

UserOAuth stores OAuth provider connections for a user. Table: user_oauth

func (UserOAuth) TableName added in v0.2.31

func (UserOAuth) TableName() string

type VerificationToken added in v0.2.31

type VerificationToken struct {
	ID        string     `gorm:"column:id;primaryKey"`
	UserID    *string    `gorm:"column:user_id;index"`
	Email     *string    `gorm:"column:email"`
	Phone     *string    `gorm:"column:phone"`
	TokenHash string     `gorm:"column:token_hash"`
	TokenType string     `gorm:"column:token_type"` // EMAIL_VERIFY, PHONE_VERIFY, PASSWORD_RESET
	ExpiresAt time.Time  `gorm:"column:expires_at"`
	UsedAt    *time.Time `gorm:"column:used_at"`
	CreatedAt time.Time  `gorm:"column:created_at;autoCreateTime"`

	// Relations
	User *User `gorm:"foreignKey:UserID"`
}

VerificationToken stores tokens for email/phone verification and password reset. Table: verification_tokens

func (VerificationToken) TableName added in v0.2.31

func (VerificationToken) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL