forked from mirrors/homebox
refactor: remove empty services (#116)
* remove empty services * remove old factory * remove old static files * cleanup more duplicate service code * file/folder reorg
This commit is contained in:
parent
6529549289
commit
cd82fe0d89
179 changed files with 514 additions and 582 deletions
96
backend/internal/data/ent/migrate/migrate.go
Normal file
96
backend/internal/data/ent/migrate/migrate.go
Normal file
|
@ -0,0 +1,96 @@
|
|||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
var (
|
||||
// WithGlobalUniqueID sets the universal ids options to the migration.
|
||||
// If this option is enabled, ent migration will allocate a 1<<32 range
|
||||
// for the ids of each entity (table).
|
||||
// Note that this option cannot be applied on tables that already exist.
|
||||
WithGlobalUniqueID = schema.WithGlobalUniqueID
|
||||
// WithDropColumn sets the drop column option to the migration.
|
||||
// If this option is enabled, ent migration will drop old columns
|
||||
// that were used for both fields and edges. This defaults to false.
|
||||
WithDropColumn = schema.WithDropColumn
|
||||
// WithDropIndex sets the drop index option to the migration.
|
||||
// If this option is enabled, ent migration will drop old indexes
|
||||
// that were defined in the schema. This defaults to false.
|
||||
// Note that unique constraints are defined using `UNIQUE INDEX`,
|
||||
// and therefore, it's recommended to enable this option to get more
|
||||
// flexibility in the schema changes.
|
||||
WithDropIndex = schema.WithDropIndex
|
||||
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
|
||||
WithForeignKeys = schema.WithForeignKeys
|
||||
)
|
||||
|
||||
// Schema is the API for creating, migrating and dropping a schema.
|
||||
type Schema struct {
|
||||
drv dialect.Driver
|
||||
}
|
||||
|
||||
// NewSchema creates a new schema client.
|
||||
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
|
||||
|
||||
// Create creates all schema resources.
|
||||
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
|
||||
return Create(ctx, s, Tables, opts...)
|
||||
}
|
||||
|
||||
// Create creates all table resources using the given schema driver.
|
||||
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
|
||||
migrate, err := schema.NewMigrate(s.drv, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ent/migrate: %w", err)
|
||||
}
|
||||
return migrate.Create(ctx, tables...)
|
||||
}
|
||||
|
||||
// Diff compares the state read from a database connection or migration directory with
|
||||
// the state defined by the Ent schema. Changes will be written to new migration files.
|
||||
func Diff(ctx context.Context, url string, opts ...schema.MigrateOption) error {
|
||||
return NamedDiff(ctx, url, "changes", opts...)
|
||||
}
|
||||
|
||||
// NamedDiff compares the state read from a database connection or migration directory with
|
||||
// the state defined by the Ent schema. Changes will be written to new named migration files.
|
||||
func NamedDiff(ctx context.Context, url, name string, opts ...schema.MigrateOption) error {
|
||||
return schema.Diff(ctx, url, name, Tables, opts...)
|
||||
}
|
||||
|
||||
// Diff creates a migration file containing the statements to resolve the diff
|
||||
// between the Ent schema and the connected database.
|
||||
func (s *Schema) Diff(ctx context.Context, opts ...schema.MigrateOption) error {
|
||||
migrate, err := schema.NewMigrate(s.drv, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ent/migrate: %w", err)
|
||||
}
|
||||
return migrate.Diff(ctx, Tables...)
|
||||
}
|
||||
|
||||
// NamedDiff creates a named migration file containing the statements to resolve the diff
|
||||
// between the Ent schema and the connected database.
|
||||
func (s *Schema) NamedDiff(ctx context.Context, name string, opts ...schema.MigrateOption) error {
|
||||
migrate, err := schema.NewMigrate(s.drv, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ent/migrate: %w", err)
|
||||
}
|
||||
return migrate.NamedDiff(ctx, name, Tables...)
|
||||
}
|
||||
|
||||
// WriteTo writes the schema changes to w instead of running them against the database.
|
||||
//
|
||||
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
|
||||
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
|
||||
}
|
407
backend/internal/data/ent/migrate/schema.go
Normal file
407
backend/internal/data/ent/migrate/schema.go
Normal file
|
@ -0,0 +1,407 @@
|
|||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
var (
|
||||
// AttachmentsColumns holds the columns for the "attachments" table.
|
||||
AttachmentsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "type", Type: field.TypeEnum, Enums: []string{"photo", "manual", "warranty", "attachment", "receipt"}, Default: "attachment"},
|
||||
{Name: "document_attachments", Type: field.TypeUUID},
|
||||
{Name: "item_attachments", Type: field.TypeUUID},
|
||||
}
|
||||
// AttachmentsTable holds the schema information for the "attachments" table.
|
||||
AttachmentsTable = &schema.Table{
|
||||
Name: "attachments",
|
||||
Columns: AttachmentsColumns,
|
||||
PrimaryKey: []*schema.Column{AttachmentsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "attachments_documents_attachments",
|
||||
Columns: []*schema.Column{AttachmentsColumns[4]},
|
||||
RefColumns: []*schema.Column{DocumentsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "attachments_items_attachments",
|
||||
Columns: []*schema.Column{AttachmentsColumns[5]},
|
||||
RefColumns: []*schema.Column{ItemsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// AuthTokensColumns holds the columns for the "auth_tokens" table.
|
||||
AuthTokensColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "token", Type: field.TypeBytes, Unique: true},
|
||||
{Name: "expires_at", Type: field.TypeTime},
|
||||
{Name: "user_auth_tokens", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
// AuthTokensTable holds the schema information for the "auth_tokens" table.
|
||||
AuthTokensTable = &schema.Table{
|
||||
Name: "auth_tokens",
|
||||
Columns: AuthTokensColumns,
|
||||
PrimaryKey: []*schema.Column{AuthTokensColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "auth_tokens_users_auth_tokens",
|
||||
Columns: []*schema.Column{AuthTokensColumns[5]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "authtokens_token",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{AuthTokensColumns[3]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// DocumentsColumns holds the columns for the "documents" table.
|
||||
DocumentsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "title", Type: field.TypeString, Size: 255},
|
||||
{Name: "path", Type: field.TypeString, Size: 500},
|
||||
{Name: "group_documents", Type: field.TypeUUID},
|
||||
}
|
||||
// DocumentsTable holds the schema information for the "documents" table.
|
||||
DocumentsTable = &schema.Table{
|
||||
Name: "documents",
|
||||
Columns: DocumentsColumns,
|
||||
PrimaryKey: []*schema.Column{DocumentsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "documents_groups_documents",
|
||||
Columns: []*schema.Column{DocumentsColumns[5]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// DocumentTokensColumns holds the columns for the "document_tokens" table.
|
||||
DocumentTokensColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "token", Type: field.TypeBytes, Unique: true},
|
||||
{Name: "uses", Type: field.TypeInt, Default: 1},
|
||||
{Name: "expires_at", Type: field.TypeTime},
|
||||
{Name: "document_document_tokens", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
// DocumentTokensTable holds the schema information for the "document_tokens" table.
|
||||
DocumentTokensTable = &schema.Table{
|
||||
Name: "document_tokens",
|
||||
Columns: DocumentTokensColumns,
|
||||
PrimaryKey: []*schema.Column{DocumentTokensColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "document_tokens_documents_document_tokens",
|
||||
Columns: []*schema.Column{DocumentTokensColumns[6]},
|
||||
RefColumns: []*schema.Column{DocumentsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "documenttoken_token",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{DocumentTokensColumns[3]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// GroupsColumns holds the columns for the "groups" table.
|
||||
GroupsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "currency", Type: field.TypeEnum, Enums: []string{"usd", "eur", "gbp", "jpy"}, Default: "usd"},
|
||||
}
|
||||
// GroupsTable holds the schema information for the "groups" table.
|
||||
GroupsTable = &schema.Table{
|
||||
Name: "groups",
|
||||
Columns: GroupsColumns,
|
||||
PrimaryKey: []*schema.Column{GroupsColumns[0]},
|
||||
}
|
||||
// GroupInvitationTokensColumns holds the columns for the "group_invitation_tokens" table.
|
||||
GroupInvitationTokensColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "token", Type: field.TypeBytes, Unique: true},
|
||||
{Name: "expires_at", Type: field.TypeTime},
|
||||
{Name: "uses", Type: field.TypeInt, Default: 0},
|
||||
{Name: "group_invitation_tokens", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
// GroupInvitationTokensTable holds the schema information for the "group_invitation_tokens" table.
|
||||
GroupInvitationTokensTable = &schema.Table{
|
||||
Name: "group_invitation_tokens",
|
||||
Columns: GroupInvitationTokensColumns,
|
||||
PrimaryKey: []*schema.Column{GroupInvitationTokensColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "group_invitation_tokens_groups_invitation_tokens",
|
||||
Columns: []*schema.Column{GroupInvitationTokensColumns[6]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// ItemsColumns holds the columns for the "items" table.
|
||||
ItemsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "import_ref", Type: field.TypeString, Nullable: true, Size: 100},
|
||||
{Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "quantity", Type: field.TypeInt, Default: 1},
|
||||
{Name: "insured", Type: field.TypeBool, Default: false},
|
||||
{Name: "serial_number", Type: field.TypeString, Nullable: true, Size: 255},
|
||||
{Name: "model_number", Type: field.TypeString, Nullable: true, Size: 255},
|
||||
{Name: "manufacturer", Type: field.TypeString, Nullable: true, Size: 255},
|
||||
{Name: "lifetime_warranty", Type: field.TypeBool, Default: false},
|
||||
{Name: "warranty_expires", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "warranty_details", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "purchase_time", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "purchase_from", Type: field.TypeString, Nullable: true},
|
||||
{Name: "purchase_price", Type: field.TypeFloat64, Default: 0},
|
||||
{Name: "sold_time", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "sold_to", Type: field.TypeString, Nullable: true},
|
||||
{Name: "sold_price", Type: field.TypeFloat64, Default: 0},
|
||||
{Name: "sold_notes", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "group_items", Type: field.TypeUUID},
|
||||
{Name: "item_children", Type: field.TypeUUID, Nullable: true},
|
||||
{Name: "location_items", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
// ItemsTable holds the schema information for the "items" table.
|
||||
ItemsTable = &schema.Table{
|
||||
Name: "items",
|
||||
Columns: ItemsColumns,
|
||||
PrimaryKey: []*schema.Column{ItemsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "items_groups_items",
|
||||
Columns: []*schema.Column{ItemsColumns[22]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "items_items_children",
|
||||
Columns: []*schema.Column{ItemsColumns[23]},
|
||||
RefColumns: []*schema.Column{ItemsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
{
|
||||
Symbol: "items_locations_items",
|
||||
Columns: []*schema.Column{ItemsColumns[24]},
|
||||
RefColumns: []*schema.Column{LocationsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "item_name",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ItemsColumns[3]},
|
||||
},
|
||||
{
|
||||
Name: "item_manufacturer",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ItemsColumns[11]},
|
||||
},
|
||||
{
|
||||
Name: "item_model_number",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ItemsColumns[10]},
|
||||
},
|
||||
{
|
||||
Name: "item_serial_number",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ItemsColumns[9]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// ItemFieldsColumns holds the columns for the "item_fields" table.
|
||||
ItemFieldsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "type", Type: field.TypeEnum, Enums: []string{"text", "number", "boolean", "time"}},
|
||||
{Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500},
|
||||
{Name: "number_value", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "boolean_value", Type: field.TypeBool, Default: false},
|
||||
{Name: "time_value", Type: field.TypeTime},
|
||||
{Name: "item_fields", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
// ItemFieldsTable holds the schema information for the "item_fields" table.
|
||||
ItemFieldsTable = &schema.Table{
|
||||
Name: "item_fields",
|
||||
Columns: ItemFieldsColumns,
|
||||
PrimaryKey: []*schema.Column{ItemFieldsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "item_fields_items_fields",
|
||||
Columns: []*schema.Column{ItemFieldsColumns[10]},
|
||||
RefColumns: []*schema.Column{ItemsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// LabelsColumns holds the columns for the "labels" table.
|
||||
LabelsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "color", Type: field.TypeString, Nullable: true, Size: 255},
|
||||
{Name: "group_labels", Type: field.TypeUUID},
|
||||
}
|
||||
// LabelsTable holds the schema information for the "labels" table.
|
||||
LabelsTable = &schema.Table{
|
||||
Name: "labels",
|
||||
Columns: LabelsColumns,
|
||||
PrimaryKey: []*schema.Column{LabelsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "labels_groups_labels",
|
||||
Columns: []*schema.Column{LabelsColumns[6]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// LocationsColumns holds the columns for the "locations" table.
|
||||
LocationsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "group_locations", Type: field.TypeUUID},
|
||||
{Name: "location_children", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
// LocationsTable holds the schema information for the "locations" table.
|
||||
LocationsTable = &schema.Table{
|
||||
Name: "locations",
|
||||
Columns: LocationsColumns,
|
||||
PrimaryKey: []*schema.Column{LocationsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "locations_groups_locations",
|
||||
Columns: []*schema.Column{LocationsColumns[5]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "locations_locations_children",
|
||||
Columns: []*schema.Column{LocationsColumns[6]},
|
||||
RefColumns: []*schema.Column{LocationsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
}
|
||||
// UsersColumns holds the columns for the "users" table.
|
||||
UsersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "email", Type: field.TypeString, Unique: true, Size: 255},
|
||||
{Name: "password", Type: field.TypeString, Size: 255},
|
||||
{Name: "is_superuser", Type: field.TypeBool, Default: false},
|
||||
{Name: "role", Type: field.TypeEnum, Enums: []string{"user", "owner"}, Default: "user"},
|
||||
{Name: "superuser", Type: field.TypeBool, Default: false},
|
||||
{Name: "activated_on", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "group_users", Type: field.TypeUUID},
|
||||
}
|
||||
// UsersTable holds the schema information for the "users" table.
|
||||
UsersTable = &schema.Table{
|
||||
Name: "users",
|
||||
Columns: UsersColumns,
|
||||
PrimaryKey: []*schema.Column{UsersColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "users_groups_users",
|
||||
Columns: []*schema.Column{UsersColumns[10]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// LabelItemsColumns holds the columns for the "label_items" table.
|
||||
LabelItemsColumns = []*schema.Column{
|
||||
{Name: "label_id", Type: field.TypeUUID},
|
||||
{Name: "item_id", Type: field.TypeUUID},
|
||||
}
|
||||
// LabelItemsTable holds the schema information for the "label_items" table.
|
||||
LabelItemsTable = &schema.Table{
|
||||
Name: "label_items",
|
||||
Columns: LabelItemsColumns,
|
||||
PrimaryKey: []*schema.Column{LabelItemsColumns[0], LabelItemsColumns[1]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "label_items_label_id",
|
||||
Columns: []*schema.Column{LabelItemsColumns[0]},
|
||||
RefColumns: []*schema.Column{LabelsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "label_items_item_id",
|
||||
Columns: []*schema.Column{LabelItemsColumns[1]},
|
||||
RefColumns: []*schema.Column{ItemsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// Tables holds all the tables in the schema.
|
||||
Tables = []*schema.Table{
|
||||
AttachmentsTable,
|
||||
AuthTokensTable,
|
||||
DocumentsTable,
|
||||
DocumentTokensTable,
|
||||
GroupsTable,
|
||||
GroupInvitationTokensTable,
|
||||
ItemsTable,
|
||||
ItemFieldsTable,
|
||||
LabelsTable,
|
||||
LocationsTable,
|
||||
UsersTable,
|
||||
LabelItemsTable,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
AttachmentsTable.ForeignKeys[0].RefTable = DocumentsTable
|
||||
AttachmentsTable.ForeignKeys[1].RefTable = ItemsTable
|
||||
AuthTokensTable.ForeignKeys[0].RefTable = UsersTable
|
||||
DocumentsTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
DocumentTokensTable.ForeignKeys[0].RefTable = DocumentsTable
|
||||
GroupInvitationTokensTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
ItemsTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
ItemsTable.ForeignKeys[1].RefTable = ItemsTable
|
||||
ItemsTable.ForeignKeys[2].RefTable = LocationsTable
|
||||
ItemFieldsTable.ForeignKeys[0].RefTable = ItemsTable
|
||||
LabelsTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
LocationsTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
LocationsTable.ForeignKeys[1].RefTable = LocationsTable
|
||||
UsersTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
LabelItemsTable.ForeignKeys[0].RefTable = LabelsTable
|
||||
LabelItemsTable.ForeignKeys[1].RefTable = ItemsTable
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue