Documentation
¶
Index ¶
- Variables
- func Create(ctx context.Context, s *Schema, tables []*schema.Table, ...) error
- func Diff(ctx context.Context, url string, opts ...schema.MigrateOption) error
- func NamedDiff(ctx context.Context, url, name string, opts ...schema.MigrateOption) error
- type Schema
- func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) Diff(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) NamedDiff(ctx context.Context, name string, opts ...schema.MigrateOption) error
- func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error
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 ( // APIKeysColumns holds the columns for the "api_keys" table. APIKeysColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "name", Type: field.TypeString}, {Name: "key_hash", Type: field.TypeString}, {Name: "last_used_at", Type: field.TypeTime, Nullable: true}, {Name: "user_api_keys", Type: field.TypeUint32}, } // APIKeysTable holds the schema information for the "api_keys" table. APIKeysTable = &schema.Table{ Name: "api_keys", Columns: APIKeysColumns, PrimaryKey: []*schema.Column{APIKeysColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "api_keys_users_api_keys", Columns: []*schema.Column{APIKeysColumns[6]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // DownloadRecordsColumns holds the columns for the "download_records" table. DownloadRecordsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "title", Type: field.TypeString}, {Name: "quality", Type: field.TypeString, Nullable: true}, {Name: "size", Type: field.TypeInt64, Nullable: true}, {Name: "status", Type: field.TypeEnum, Enums: []string{"downloading", "importing", "completed", "failed", "pending", "dismissed"}, Default: "downloading"}, {Name: "torrent_hash", Type: field.TypeString, Nullable: true}, {Name: "release_group", Type: field.TypeString, Nullable: true}, {Name: "save_path", Type: field.TypeString, Nullable: true}, {Name: "import_attempts", Type: field.TypeUint8, Default: 0}, {Name: "failure_reason", Type: field.TypeString, Nullable: true}, {Name: "imported_at", Type: field.TypeTime, Nullable: true}, {Name: "indexer_name", Type: field.TypeString, Nullable: true}, {Name: "download_client_name", Type: field.TypeString, Nullable: true}, {Name: "replace_existing", Type: field.TypeBool, Default: false}, {Name: "episode_download_records", Type: field.TypeUint32, Nullable: true}, {Name: "movie_download_records", Type: field.TypeUint32, Nullable: true}, } // DownloadRecordsTable holds the schema information for the "download_records" table. DownloadRecordsTable = &schema.Table{ Name: "download_records", Columns: DownloadRecordsColumns, PrimaryKey: []*schema.Column{DownloadRecordsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "download_records_episodes_download_records", Columns: []*schema.Column{DownloadRecordsColumns[16]}, RefColumns: []*schema.Column{EpisodesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "download_records_movies_download_records", Columns: []*schema.Column{DownloadRecordsColumns[17]}, RefColumns: []*schema.Column{MoviesColumns[0]}, OnDelete: schema.SetNull, }, }, } // EpisodesColumns holds the columns for the "episodes" table. EpisodesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "number", Type: field.TypeUint16}, {Name: "title", Type: field.TypeString, Nullable: true}, {Name: "air_date", Type: field.TypeTime, Nullable: true}, {Name: "monitored", Type: field.TypeBool, Default: true}, {Name: "absolute_number", Type: field.TypeUint16, Nullable: true, Default: 0}, {Name: "grab_failures", Type: field.TypeUint8, Default: 0}, {Name: "last_search_at", Type: field.TypeTime, Nullable: true}, {Name: "status", Type: field.TypeEnum, Enums: []string{"wanted", "downloading", "paused", "available", "skipped"}, Default: "wanted"}, {Name: "season_episodes", Type: field.TypeUint32}, } // EpisodesTable holds the schema information for the "episodes" table. EpisodesTable = &schema.Table{ Name: "episodes", Columns: EpisodesColumns, PrimaryKey: []*schema.Column{EpisodesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "episodes_seasons_episodes", Columns: []*schema.Column{EpisodesColumns[11]}, RefColumns: []*schema.Column{SeasonsColumns[0]}, OnDelete: schema.Cascade, }, }, } // ImportScansColumns holds the columns for the "import_scans" table. ImportScansColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "source_path", Type: field.TypeString}, {Name: "kind", Type: field.TypeEnum, Enums: []string{"movie", "series"}, Default: "movie"}, {Name: "mode", Type: field.TypeEnum, Enums: []string{"in_place", "rename"}}, {Name: "import_mode", Type: field.TypeEnum, Nullable: true, Enums: []string{"hardlink", "copy", "move"}}, {Name: "status", Type: field.TypeEnum, Enums: []string{"running", "awaiting_review", "committing", "completed", "cancelled", "failed"}, Default: "running"}, {Name: "total_count", Type: field.TypeUint32, Default: 0}, {Name: "processed_count", Type: field.TypeUint32, Default: 0}, {Name: "commit_success_count", Type: field.TypeUint32, Default: 0}, {Name: "commit_failed_count", Type: field.TypeUint32, Default: 0}, {Name: "failure_reason", Type: field.TypeString, Nullable: true}, {Name: "scanned_at", Type: field.TypeTime, Nullable: true}, {Name: "committed_at", Type: field.TypeTime, Nullable: true}, } // ImportScansTable holds the schema information for the "import_scans" table. ImportScansTable = &schema.Table{ Name: "import_scans", Columns: ImportScansColumns, PrimaryKey: []*schema.Column{ImportScansColumns[0]}, Indexes: []*schema.Index{ { Name: "importscan_status", Unique: false, Columns: []*schema.Column{ImportScansColumns[7]}, }, { Name: "importscan_kind", Unique: false, Columns: []*schema.Column{ImportScansColumns[4]}, }, }, } // ImportScanFilesColumns holds the columns for the "import_scan_files" table. ImportScanFilesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "source_path", Type: field.TypeString}, {Name: "size", Type: field.TypeInt64}, {Name: "parsed_title", Type: field.TypeString, Nullable: true}, {Name: "parsed_year", Type: field.TypeUint16, Nullable: true}, {Name: "parsed_quality", Type: field.TypeString, Nullable: true}, {Name: "parsed_release_group", Type: field.TypeString, Nullable: true}, {Name: "classification", Type: field.TypeEnum, Enums: []string{"confirmed", "ambiguous", "unmatched", "existing"}, Default: "unmatched"}, {Name: "candidates", Type: field.TypeJSON, Nullable: true}, {Name: "tmdb_id", Type: field.TypeUint32, Nullable: true}, {Name: "existing_movie_id", Type: field.TypeUint32, Nullable: true}, {Name: "decision", Type: field.TypeEnum, Enums: []string{"pending", "accept", "skip"}, Default: "pending"}, {Name: "decision_tmdb_id", Type: field.TypeUint32, Nullable: true}, {Name: "outcome", Type: field.TypeEnum, Enums: []string{"pending", "created", "attached", "skipped", "failed"}, Default: "pending"}, {Name: "outcome_message", Type: field.TypeString, Nullable: true}, {Name: "created_movie_id", Type: field.TypeUint32, Nullable: true}, {Name: "import_scan_files", Type: field.TypeUint32}, } // ImportScanFilesTable holds the schema information for the "import_scan_files" table. ImportScanFilesTable = &schema.Table{ Name: "import_scan_files", Columns: ImportScanFilesColumns, PrimaryKey: []*schema.Column{ImportScanFilesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "import_scan_files_import_scans_files", Columns: []*schema.Column{ImportScanFilesColumns[18]}, RefColumns: []*schema.Column{ImportScansColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "importscanfile_classification", Unique: false, Columns: []*schema.Column{ImportScanFilesColumns[9]}, }, { Name: "importscanfile_decision", Unique: false, Columns: []*schema.Column{ImportScanFilesColumns[13]}, }, }, } // ImportScanShowsColumns holds the columns for the "import_scan_shows" table. ImportScanShowsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "folder_path", Type: field.TypeString}, {Name: "parsed_title", Type: field.TypeString, Nullable: true}, {Name: "parsed_year", Type: field.TypeUint16, Nullable: true}, {Name: "classification", Type: field.TypeEnum, Enums: []string{"confirmed", "ambiguous", "unmatched", "existing"}, Default: "unmatched"}, {Name: "tvdb_id", Type: field.TypeUint32, Nullable: true}, {Name: "candidates", Type: field.TypeJSON, Nullable: true}, {Name: "existing_tvshow_id", Type: field.TypeUint32, Nullable: true}, {Name: "file_count", Type: field.TypeUint16, Default: 0}, {Name: "decision", Type: field.TypeEnum, Enums: []string{"pending", "accept", "skip"}, Default: "pending"}, {Name: "decision_tvdb_id", Type: field.TypeUint32, Nullable: true}, {Name: "outcome", Type: field.TypeEnum, Enums: []string{"pending", "created", "failed"}, Default: "pending"}, {Name: "outcome_message", Type: field.TypeString, Nullable: true}, {Name: "created_tvshow_id", Type: field.TypeUint32, Nullable: true}, {Name: "import_scan_shows", Type: field.TypeUint32}, } // ImportScanShowsTable holds the schema information for the "import_scan_shows" table. ImportScanShowsTable = &schema.Table{ Name: "import_scan_shows", Columns: ImportScanShowsColumns, PrimaryKey: []*schema.Column{ImportScanShowsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "import_scan_shows_import_scans_shows", Columns: []*schema.Column{ImportScanShowsColumns[16]}, RefColumns: []*schema.Column{ImportScansColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "importscanshow_classification", Unique: false, Columns: []*schema.Column{ImportScanShowsColumns[6]}, }, { Name: "importscanshow_decision", Unique: false, Columns: []*schema.Column{ImportScanShowsColumns[11]}, }, }, } // InvitesColumns holds the columns for the "invites" table. InvitesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "token_hash", Type: field.TypeString, Unique: true}, {Name: "email", Type: field.TypeString, Nullable: true}, {Name: "role", Type: field.TypeEnum, Enums: []string{"admin", "member", "request_only"}, Default: "member"}, {Name: "expires_at", Type: field.TypeTime}, {Name: "used_at", Type: field.TypeTime, Nullable: true}, {Name: "invite_created_by", Type: field.TypeUint32}, {Name: "invite_used_by", Type: field.TypeUint32, Nullable: true}, } // InvitesTable holds the schema information for the "invites" table. InvitesTable = &schema.Table{ Name: "invites", Columns: InvitesColumns, PrimaryKey: []*schema.Column{InvitesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "invites_users_created_by", Columns: []*schema.Column{InvitesColumns[8]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "invites_users_used_by", Columns: []*schema.Column{InvitesColumns[9]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, } // MediaFilesColumns holds the columns for the "media_files" table. MediaFilesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "path", Type: field.TypeString}, {Name: "size", Type: field.TypeInt64}, {Name: "quality", Type: field.TypeString, Nullable: true}, {Name: "format", Type: field.TypeString, Nullable: true}, {Name: "release_group", Type: field.TypeString, Nullable: true}, {Name: "source", Type: field.TypeEnum, Enums: []string{"wizard", "orphan", "auto"}, Default: "auto"}, {Name: "last_seen_at", Type: field.TypeTime, Nullable: true}, {Name: "episode_media_files", Type: field.TypeUint32, Nullable: true}, {Name: "movie_media_files", Type: field.TypeUint32, Nullable: true}, } // MediaFilesTable holds the schema information for the "media_files" table. MediaFilesTable = &schema.Table{ Name: "media_files", Columns: MediaFilesColumns, PrimaryKey: []*schema.Column{MediaFilesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "media_files_episodes_media_files", Columns: []*schema.Column{MediaFilesColumns[10]}, RefColumns: []*schema.Column{EpisodesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "media_files_movies_media_files", Columns: []*schema.Column{MediaFilesColumns[11]}, RefColumns: []*schema.Column{MoviesColumns[0]}, OnDelete: schema.SetNull, }, }, } // MoviesColumns holds the columns for the "movies" table. MoviesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "title", Type: field.TypeString}, {Name: "original_title", Type: field.TypeString}, {Name: "year", Type: field.TypeUint16}, {Name: "overview", Type: field.TypeString, Nullable: true}, {Name: "runtime", Type: field.TypeUint16, Nullable: true, Default: 0}, {Name: "status", Type: field.TypeEnum, Enums: []string{"wanted", "downloading", "available", "failed"}, Default: "wanted"}, {Name: "monitored", Type: field.TypeBool, Default: true}, {Name: "tmdb_id", Type: field.TypeUint32, Unique: true}, {Name: "last_search_at", Type: field.TypeTime, Nullable: true}, {Name: "digital_release_date", Type: field.TypeTime, Nullable: true}, {Name: "grab_failures", Type: field.TypeUint8, Default: 0}, {Name: "failure_reason", Type: field.TypeString, Nullable: true}, {Name: "quality_profile", Type: field.TypeString, Nullable: true}, } // MoviesTable holds the schema information for the "movies" table. MoviesTable = &schema.Table{ Name: "movies", Columns: MoviesColumns, PrimaryKey: []*schema.Column{MoviesColumns[0]}, Indexes: []*schema.Index{ { Name: "movie_digital_release_date", Unique: false, Columns: []*schema.Column{MoviesColumns[12]}, }, }, } // MovieEventsColumns holds the columns for the "movie_events" table. MovieEventsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "type", Type: field.TypeEnum, Enums: []string{"grabbed", "download_completed", "download_failed", "imported", "import_failed", "drift_detected", "drift_confirmed", "searched"}}, {Name: "payload", Type: field.TypeJSON, Nullable: true}, {Name: "movie_events", Type: field.TypeUint32}, } // MovieEventsTable holds the schema information for the "movie_events" table. MovieEventsTable = &schema.Table{ Name: "movie_events", Columns: MovieEventsColumns, PrimaryKey: []*schema.Column{MovieEventsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "movie_events_movies_events", Columns: []*schema.Column{MovieEventsColumns[5]}, RefColumns: []*schema.Column{MoviesColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "movieevent_create_time", Unique: false, Columns: []*schema.Column{MovieEventsColumns[1]}, }, { Name: "movieevent_type_create_time", Unique: false, Columns: []*schema.Column{MovieEventsColumns[3], MovieEventsColumns[1]}, }, { Name: "movieevent_create_time_movie_events", Unique: false, Columns: []*schema.Column{MovieEventsColumns[1], MovieEventsColumns[5]}, }, }, } // OidcIdentitiesColumns holds the columns for the "oidc_identities" table. OidcIdentitiesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "provider", Type: field.TypeString}, {Name: "subject", Type: field.TypeString}, {Name: "email", Type: field.TypeString, Nullable: true}, {Name: "user_oidc_identities", Type: field.TypeUint32}, } // OidcIdentitiesTable holds the schema information for the "oidc_identities" table. OidcIdentitiesTable = &schema.Table{ Name: "oidc_identities", Columns: OidcIdentitiesColumns, PrimaryKey: []*schema.Column{OidcIdentitiesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "oidc_identities_users_oidc_identities", Columns: []*schema.Column{OidcIdentitiesColumns[6]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "oidcidentity_provider_subject", Unique: true, Columns: []*schema.Column{OidcIdentitiesColumns[3], OidcIdentitiesColumns[4]}, }, }, } // RequestsColumns holds the columns for the "requests" table. RequestsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "media_type", Type: field.TypeEnum, Enums: []string{"movie", "tvshow"}}, {Name: "media_id", Type: field.TypeUint32}, {Name: "title", Type: field.TypeString}, {Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "approved", "denied", "available"}, Default: "pending"}, {Name: "reason", Type: field.TypeString, Nullable: true}, {Name: "request_approved_by", Type: field.TypeUint32, Nullable: true}, {Name: "user_requests", Type: field.TypeUint32}, } // RequestsTable holds the schema information for the "requests" table. RequestsTable = &schema.Table{ Name: "requests", Columns: RequestsColumns, PrimaryKey: []*schema.Column{RequestsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "requests_users_approved_by", Columns: []*schema.Column{RequestsColumns[8]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "requests_users_requests", Columns: []*schema.Column{RequestsColumns[9]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // ScheduledJobsColumns holds the columns for the "scheduled_jobs" table. ScheduledJobsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "name", Type: field.TypeString, Unique: true}, {Name: "paused", Type: field.TypeBool, Default: false}, {Name: "last_started_at", Type: field.TypeTime, Nullable: true}, {Name: "last_finished_at", Type: field.TypeTime, Nullable: true}, {Name: "last_status", Type: field.TypeEnum, Enums: []string{"never", "success", "error", "skipped"}, Default: "never"}, {Name: "last_error", Type: field.TypeString, Nullable: true}, {Name: "last_duration_ms", Type: field.TypeUint32, Default: 0}, } // ScheduledJobsTable holds the schema information for the "scheduled_jobs" table. ScheduledJobsTable = &schema.Table{ Name: "scheduled_jobs", Columns: ScheduledJobsColumns, PrimaryKey: []*schema.Column{ScheduledJobsColumns[0]}, } // SeasonsColumns holds the columns for the "seasons" table. SeasonsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "number", Type: field.TypeUint16}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "monitored", Type: field.TypeBool, Default: true}, {Name: "tv_show_seasons", Type: field.TypeUint32}, } // SeasonsTable holds the schema information for the "seasons" table. SeasonsTable = &schema.Table{ Name: "seasons", Columns: SeasonsColumns, PrimaryKey: []*schema.Column{SeasonsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "seasons_tv_shows_seasons", Columns: []*schema.Column{SeasonsColumns[6]}, RefColumns: []*schema.Column{TvShowsColumns[0]}, OnDelete: schema.Cascade, }, }, } // SessionsColumns holds the columns for the "sessions" table. SessionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "jti", Type: field.TypeString, Unique: true}, {Name: "expires_at", Type: field.TypeTime}, {Name: "revoked_at", Type: field.TypeTime, Nullable: true}, {Name: "last_seen_at", Type: field.TypeTime, Nullable: true}, {Name: "ip", Type: field.TypeString, Nullable: true}, {Name: "user_agent", Type: field.TypeString, Nullable: true, Size: 512}, {Name: "user_sessions", Type: field.TypeUint32}, } // SessionsTable holds the schema information for the "sessions" table. SessionsTable = &schema.Table{ Name: "sessions", Columns: SessionsColumns, PrimaryKey: []*schema.Column{SessionsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "sessions_users_sessions", Columns: []*schema.Column{SessionsColumns[9]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // TvShowsColumns holds the columns for the "tv_shows" table. TvShowsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "title", Type: field.TypeString}, {Name: "original_title", Type: field.TypeString, Nullable: true}, {Name: "year", Type: field.TypeUint16}, {Name: "overview", Type: field.TypeString, Nullable: true}, {Name: "series_status", Type: field.TypeEnum, Enums: []string{"continuing", "ended", "upcoming"}, Default: "continuing"}, {Name: "type", Type: field.TypeEnum, Enums: []string{"standard", "anime", "daily"}, Default: "standard"}, {Name: "monitored", Type: field.TypeBool, Default: true}, {Name: "tvdb_id", Type: field.TypeUint32, Unique: true}, {Name: "poster_path", Type: field.TypeString, Nullable: true}, {Name: "network", Type: field.TypeString, Nullable: true}, {Name: "creator", Type: field.TypeString, Nullable: true}, {Name: "runtime", Type: field.TypeUint16, Nullable: true, Default: 0}, {Name: "rating", Type: field.TypeFloat64, Nullable: true, Default: 0}, {Name: "genres", Type: field.TypeJSON, Nullable: true}, {Name: "last_refreshed_at", Type: field.TypeTime, Nullable: true}, {Name: "quality_profile", Type: field.TypeString, Nullable: true}, } // TvShowsTable holds the schema information for the "tv_shows" table. TvShowsTable = &schema.Table{ Name: "tv_shows", Columns: TvShowsColumns, PrimaryKey: []*schema.Column{TvShowsColumns[0]}, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "email", Type: field.TypeString, Unique: true}, {Name: "password_hash", Type: field.TypeString, Nullable: true}, {Name: "role", Type: field.TypeEnum, Enums: []string{"admin", "member", "request_only"}, Default: "member"}, {Name: "auth_method", Type: field.TypeEnum, Enums: []string{"local", "oidc", "both"}, Default: "local"}, {Name: "display_name", Type: field.TypeString, Nullable: true}, {Name: "failed_login_count", Type: field.TypeUint8, Default: 0}, {Name: "last_failed_login_at", Type: field.TypeTime, Nullable: true}, {Name: "locked_until", Type: field.TypeTime, Nullable: true}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ Name: "users", Columns: UsersColumns, PrimaryKey: []*schema.Column{UsersColumns[0]}, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ APIKeysTable, DownloadRecordsTable, EpisodesTable, ImportScansTable, ImportScanFilesTable, ImportScanShowsTable, InvitesTable, MediaFilesTable, MoviesTable, MovieEventsTable, OidcIdentitiesTable, RequestsTable, ScheduledJobsTable, SeasonsTable, SessionsTable, TvShowsTable, UsersTable, } )
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 (*Schema) Diff ¶
Diff creates a migration file containing the statements to resolve the diff between the Ent schema and the connected database.
func (*Schema) NamedDiff ¶
NamedDiff creates a named migration file containing the statements to resolve the diff between the Ent schema and the connected database.
Click to show internal directories.
Click to hide internal directories.