migrate

package
v4.0.0-...-5b82330 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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
)
View Source
var (
	// DavAccountsColumns holds the columns for the "dav_accounts" table.
	DavAccountsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "name", Type: field.TypeString},
		{Name: "uri", Type: field.TypeString, Size: 2147483647},
		{Name: "password", Type: field.TypeString},
		{Name: "options", Type: field.TypeBytes},
		{Name: "props", Type: field.TypeJSON, Nullable: true},
		{Name: "owner_id", Type: field.TypeInt},
	}
	// DavAccountsTable holds the schema information for the "dav_accounts" table.
	DavAccountsTable = &schema.Table{
		Name:       "dav_accounts",
		Columns:    DavAccountsColumns,
		PrimaryKey: []*schema.Column{DavAccountsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "dav_accounts_users_dav_accounts",
				Columns:    []*schema.Column{DavAccountsColumns[9]},
				RefColumns: []*schema.Column{UsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "davaccount_owner_id_password",
				Unique:  true,
				Columns: []*schema.Column{DavAccountsColumns[9], DavAccountsColumns[6]},
			},
		},
	}
	// DirectLinksColumns holds the columns for the "direct_links" table.
	DirectLinksColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "name", Type: field.TypeString},
		{Name: "downloads", Type: field.TypeInt},
		{Name: "speed", Type: field.TypeInt},
		{Name: "file_id", Type: field.TypeInt},
	}
	// DirectLinksTable holds the schema information for the "direct_links" table.
	DirectLinksTable = &schema.Table{
		Name:       "direct_links",
		Columns:    DirectLinksColumns,
		PrimaryKey: []*schema.Column{DirectLinksColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "direct_links_files_direct_links",
				Columns:    []*schema.Column{DirectLinksColumns[7]},
				RefColumns: []*schema.Column{FilesColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
	}
	// EntitiesColumns holds the columns for the "entities" table.
	EntitiesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "type", Type: field.TypeInt},
		{Name: "source", Type: field.TypeString, Size: 2147483647},
		{Name: "size", Type: field.TypeInt64},
		{Name: "reference_count", Type: field.TypeInt, Default: 1},
		{Name: "upload_session_id", Type: field.TypeUUID, Nullable: true},
		{Name: "recycle_options", Type: field.TypeJSON, Nullable: true},
		{Name: "storage_policy_entities", Type: field.TypeInt},
		{Name: "created_by", Type: field.TypeInt, Nullable: true},
	}
	// EntitiesTable holds the schema information for the "entities" table.
	EntitiesTable = &schema.Table{
		Name:       "entities",
		Columns:    EntitiesColumns,
		PrimaryKey: []*schema.Column{EntitiesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "entities_storage_policies_entities",
				Columns:    []*schema.Column{EntitiesColumns[10]},
				RefColumns: []*schema.Column{StoragePoliciesColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "entities_users_entities",
				Columns:    []*schema.Column{EntitiesColumns[11]},
				RefColumns: []*schema.Column{UsersColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// FilesColumns holds the columns for the "files" table.
	FilesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "type", Type: field.TypeInt},
		{Name: "name", Type: field.TypeString},
		{Name: "size", Type: field.TypeInt64, Default: 0},
		{Name: "primary_entity", Type: field.TypeInt, Nullable: true},
		{Name: "is_symbolic", Type: field.TypeBool, Default: false},
		{Name: "props", Type: field.TypeJSON, Nullable: true},
		{Name: "file_children", Type: field.TypeInt, Nullable: true},
		{Name: "storage_policy_files", Type: field.TypeInt, Nullable: true},
		{Name: "owner_id", Type: field.TypeInt},
	}
	// FilesTable holds the schema information for the "files" table.
	FilesTable = &schema.Table{
		Name:       "files",
		Columns:    FilesColumns,
		PrimaryKey: []*schema.Column{FilesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "files_files_children",
				Columns:    []*schema.Column{FilesColumns[9]},
				RefColumns: []*schema.Column{FilesColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "files_storage_policies_files",
				Columns:    []*schema.Column{FilesColumns[10]},
				RefColumns: []*schema.Column{StoragePoliciesColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "files_users_files",
				Columns:    []*schema.Column{FilesColumns[11]},
				RefColumns: []*schema.Column{UsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "file_file_children_name",
				Unique:  true,
				Columns: []*schema.Column{FilesColumns[9], FilesColumns[4]},
			},
			{
				Name:    "file_file_children_type_updated_at",
				Unique:  false,
				Columns: []*schema.Column{FilesColumns[9], FilesColumns[3], FilesColumns[2]},
			},
			{
				Name:    "file_file_children_type_size",
				Unique:  false,
				Columns: []*schema.Column{FilesColumns[9], FilesColumns[3], FilesColumns[5]},
			},
		},
	}
	// FsEventsColumns holds the columns for the "fs_events" table.
	FsEventsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "event", Type: field.TypeString, Size: 2147483647},
		{Name: "subscriber", Type: field.TypeUUID},
		{Name: "user_fsevent", Type: field.TypeInt, Nullable: true},
	}
	// FsEventsTable holds the schema information for the "fs_events" table.
	FsEventsTable = &schema.Table{
		Name:       "fs_events",
		Columns:    FsEventsColumns,
		PrimaryKey: []*schema.Column{FsEventsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "fs_events_users_fsevents",
				Columns:    []*schema.Column{FsEventsColumns[6]},
				RefColumns: []*schema.Column{UsersColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// GroupsColumns holds the columns for the "groups" table.
	GroupsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "name", Type: field.TypeString},
		{Name: "max_storage", Type: field.TypeInt64, Nullable: true},
		{Name: "speed_limit", Type: field.TypeInt, Nullable: true},
		{Name: "permissions", Type: field.TypeBytes},
		{Name: "settings", Type: field.TypeJSON, Nullable: true},
		{Name: "storage_policy_id", Type: field.TypeInt, Nullable: true},
	}
	// GroupsTable holds the schema information for the "groups" table.
	GroupsTable = &schema.Table{
		Name:       "groups",
		Columns:    GroupsColumns,
		PrimaryKey: []*schema.Column{GroupsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "groups_storage_policies_groups",
				Columns:    []*schema.Column{GroupsColumns[9]},
				RefColumns: []*schema.Column{StoragePoliciesColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// MetadataColumns holds the columns for the "metadata" table.
	MetadataColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "name", Type: field.TypeString},
		{Name: "value", Type: field.TypeString, Size: 2147483647},
		{Name: "is_public", Type: field.TypeBool, Default: false},
		{Name: "file_id", Type: field.TypeInt},
	}
	// MetadataTable holds the schema information for the "metadata" table.
	MetadataTable = &schema.Table{
		Name:       "metadata",
		Columns:    MetadataColumns,
		PrimaryKey: []*schema.Column{MetadataColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "metadata_files_metadata",
				Columns:    []*schema.Column{MetadataColumns[7]},
				RefColumns: []*schema.Column{FilesColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "metadata_file_id_name",
				Unique:  true,
				Columns: []*schema.Column{MetadataColumns[7], MetadataColumns[4]},
			},
		},
	}
	// NodesColumns holds the columns for the "nodes" table.
	NodesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "status", Type: field.TypeEnum, Enums: []string{"active", "suspended"}},
		{Name: "name", Type: field.TypeString},
		{Name: "type", Type: field.TypeEnum, Enums: []string{"master", "slave"}},
		{Name: "server", Type: field.TypeString, Nullable: true},
		{Name: "slave_key", Type: field.TypeString, Nullable: true},
		{Name: "capabilities", Type: field.TypeBytes},
		{Name: "settings", Type: field.TypeJSON, Nullable: true},
		{Name: "weight", Type: field.TypeInt, Default: 0},
	}
	// NodesTable holds the schema information for the "nodes" table.
	NodesTable = &schema.Table{
		Name:       "nodes",
		Columns:    NodesColumns,
		PrimaryKey: []*schema.Column{NodesColumns[0]},
	}
	// OauthClientsColumns holds the columns for the "oauth_clients" table.
	OauthClientsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "guid", Type: field.TypeString, Unique: true, Size: 255},
		{Name: "secret", Type: field.TypeString, Size: 255},
		{Name: "name", Type: field.TypeString, Size: 255},
		{Name: "homepage_url", Type: field.TypeString, Nullable: true, Size: 2048},
		{Name: "redirect_uris", Type: field.TypeJSON},
		{Name: "scopes", Type: field.TypeJSON},
		{Name: "props", Type: field.TypeJSON},
		{Name: "is_enabled", Type: field.TypeBool, Default: true},
	}
	// OauthClientsTable holds the schema information for the "oauth_clients" table.
	OauthClientsTable = &schema.Table{
		Name:       "oauth_clients",
		Columns:    OauthClientsColumns,
		PrimaryKey: []*schema.Column{OauthClientsColumns[0]},
	}
	// OauthGrantsColumns holds the columns for the "oauth_grants" table.
	OauthGrantsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "scopes", Type: field.TypeJSON},
		{Name: "last_used_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "client_id", Type: field.TypeInt},
		{Name: "user_id", Type: field.TypeInt},
	}
	// OauthGrantsTable holds the schema information for the "oauth_grants" table.
	OauthGrantsTable = &schema.Table{
		Name:       "oauth_grants",
		Columns:    OauthGrantsColumns,
		PrimaryKey: []*schema.Column{OauthGrantsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "oauth_grants_oauth_clients_grants",
				Columns:    []*schema.Column{OauthGrantsColumns[6]},
				RefColumns: []*schema.Column{OauthClientsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "oauth_grants_users_oauth_grants",
				Columns:    []*schema.Column{OauthGrantsColumns[7]},
				RefColumns: []*schema.Column{UsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "oauthgrant_user_id_client_id",
				Unique:  true,
				Columns: []*schema.Column{OauthGrantsColumns[7], OauthGrantsColumns[6]},
			},
		},
	}
	// PasskeysColumns holds the columns for the "passkeys" table.
	PasskeysColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "credential_id", Type: field.TypeString},
		{Name: "name", Type: field.TypeString},
		{Name: "credential", Type: field.TypeJSON},
		{Name: "used_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "user_id", Type: field.TypeInt},
	}
	// PasskeysTable holds the schema information for the "passkeys" table.
	PasskeysTable = &schema.Table{
		Name:       "passkeys",
		Columns:    PasskeysColumns,
		PrimaryKey: []*schema.Column{PasskeysColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "passkeys_users_passkey",
				Columns:    []*schema.Column{PasskeysColumns[8]},
				RefColumns: []*schema.Column{UsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "passkey_user_id_credential_id",
				Unique:  true,
				Columns: []*schema.Column{PasskeysColumns[8], PasskeysColumns[4]},
			},
		},
	}
	// SettingsColumns holds the columns for the "settings" table.
	SettingsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "name", Type: field.TypeString, Unique: true},
		{Name: "value", Type: field.TypeString, Nullable: true, Size: 2147483647},
	}
	// SettingsTable holds the schema information for the "settings" table.
	SettingsTable = &schema.Table{
		Name:       "settings",
		Columns:    SettingsColumns,
		PrimaryKey: []*schema.Column{SettingsColumns[0]},
	}
	// SharesColumns holds the columns for the "shares" table.
	SharesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "password", Type: field.TypeString, Nullable: true},
		{Name: "views", Type: field.TypeInt, Default: 0},
		{Name: "downloads", Type: field.TypeInt, Default: 0},
		{Name: "expires", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "remain_downloads", Type: field.TypeInt, Nullable: true},
		{Name: "props", Type: field.TypeJSON, Nullable: true},
		{Name: "file_shares", Type: field.TypeInt, Nullable: true},
		{Name: "user_shares", Type: field.TypeInt, Nullable: true},
	}
	// SharesTable holds the schema information for the "shares" table.
	SharesTable = &schema.Table{
		Name:       "shares",
		Columns:    SharesColumns,
		PrimaryKey: []*schema.Column{SharesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "shares_files_shares",
				Columns:    []*schema.Column{SharesColumns[10]},
				RefColumns: []*schema.Column{FilesColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "shares_users_shares",
				Columns:    []*schema.Column{SharesColumns[11]},
				RefColumns: []*schema.Column{UsersColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// StoragePoliciesColumns holds the columns for the "storage_policies" table.
	StoragePoliciesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "name", Type: field.TypeString},
		{Name: "type", Type: field.TypeString},
		{Name: "server", Type: field.TypeString, Nullable: true},
		{Name: "bucket_name", Type: field.TypeString, Nullable: true},
		{Name: "is_private", Type: field.TypeBool, Nullable: true},
		{Name: "access_key", Type: field.TypeString, Nullable: true, Size: 2147483647},
		{Name: "secret_key", Type: field.TypeString, Nullable: true, Size: 2147483647},
		{Name: "max_size", Type: field.TypeInt64, Nullable: true},
		{Name: "dir_name_rule", Type: field.TypeString, Nullable: true},
		{Name: "file_name_rule", Type: field.TypeString, Nullable: true},
		{Name: "settings", Type: field.TypeJSON, Nullable: true},
		{Name: "node_id", Type: field.TypeInt, Nullable: true},
	}
	// StoragePoliciesTable holds the schema information for the "storage_policies" table.
	StoragePoliciesTable = &schema.Table{
		Name:       "storage_policies",
		Columns:    StoragePoliciesColumns,
		PrimaryKey: []*schema.Column{StoragePoliciesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "storage_policies_nodes_storage_policy",
				Columns:    []*schema.Column{StoragePoliciesColumns[15]},
				RefColumns: []*schema.Column{NodesColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// TasksColumns holds the columns for the "tasks" table.
	TasksColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "type", Type: field.TypeString},
		{Name: "status", Type: field.TypeEnum, Enums: []string{"queued", "processing", "suspending", "error", "canceled", "completed"}, Default: "queued"},
		{Name: "public_state", Type: field.TypeJSON},
		{Name: "private_state", Type: field.TypeString, Nullable: true, Size: 2147483647},
		{Name: "correlation_id", Type: field.TypeUUID, Nullable: true},
		{Name: "user_tasks", Type: field.TypeInt, Nullable: true},
	}
	// TasksTable holds the schema information for the "tasks" table.
	TasksTable = &schema.Table{
		Name:       "tasks",
		Columns:    TasksColumns,
		PrimaryKey: []*schema.Column{TasksColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "tasks_users_tasks",
				Columns:    []*schema.Column{TasksColumns[9]},
				RefColumns: []*schema.Column{UsersColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// UsersColumns holds the columns for the "users" table.
	UsersColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime"}},
		{Name: "email", Type: field.TypeString, Unique: true, Size: 100},
		{Name: "nick", Type: field.TypeString, Size: 100},
		{Name: "password", Type: field.TypeString, Nullable: true},
		{Name: "status", Type: field.TypeEnum, Enums: []string{"active", "inactive", "manual_banned", "sys_banned"}, Default: "active"},
		{Name: "storage", Type: field.TypeInt64, Default: 0},
		{Name: "two_factor_secret", Type: field.TypeString, Nullable: true},
		{Name: "avatar", Type: field.TypeString, Nullable: true},
		{Name: "settings", Type: field.TypeJSON, Nullable: true},
		{Name: "group_users", Type: field.TypeInt},
	}
	// 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[12]},
				RefColumns: []*schema.Column{GroupsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
	}
	// FileEntitiesColumns holds the columns for the "file_entities" table.
	FileEntitiesColumns = []*schema.Column{
		{Name: "file_id", Type: field.TypeInt},
		{Name: "entity_id", Type: field.TypeInt},
	}
	// FileEntitiesTable holds the schema information for the "file_entities" table.
	FileEntitiesTable = &schema.Table{
		Name:       "file_entities",
		Columns:    FileEntitiesColumns,
		PrimaryKey: []*schema.Column{FileEntitiesColumns[0], FileEntitiesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "file_entities_file_id",
				Columns:    []*schema.Column{FileEntitiesColumns[0]},
				RefColumns: []*schema.Column{FilesColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "file_entities_entity_id",
				Columns:    []*schema.Column{FileEntitiesColumns[1]},
				RefColumns: []*schema.Column{EntitiesColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		DavAccountsTable,
		DirectLinksTable,
		EntitiesTable,
		FilesTable,
		FsEventsTable,
		GroupsTable,
		MetadataTable,
		NodesTable,
		OauthClientsTable,
		OauthGrantsTable,
		PasskeysTable,
		SettingsTable,
		SharesTable,
		StoragePoliciesTable,
		TasksTable,
		UsersTable,
		FileEntitiesTable,
	}
)

Functions

func Create

func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error

Create creates all table resources using the given schema driver.

Types

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema is the API for creating, migrating and dropping a schema.

func NewSchema

func NewSchema(drv dialect.Driver) *Schema

NewSchema creates a new schema client.

func (*Schema) Create

func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error

Create creates all schema resources.

func (*Schema) WriteTo

func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error

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)
}

Jump to

Keyboard shortcuts

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