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 // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to false. WithFixture = schema.WithFixture // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. WithForeignKeys = schema.WithForeignKeys )
View Source
var ( // ArtistsColumns holds the columns for the "artists" table. ArtistsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString, Unique: true}, {Name: "birthday", Type: field.TypeTime, Nullable: true}, {Name: "artist_profile_picture", Type: field.TypeInt, Nullable: true}, } // ArtistsTable holds the schema information for the "artists" table. ArtistsTable = &schema.Table{ Name: "artists", Columns: ArtistsColumns, PrimaryKey: []*schema.Column{ArtistsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "artists_pictures_profile_picture", Columns: []*schema.Column{ArtistsColumns[3]}, RefColumns: []*schema.Column{PicturesColumns[0]}, OnDelete: schema.SetNull, }, }, } // CountriesColumns holds the columns for the "countries" table. CountriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString}, {Name: "code", Type: field.TypeString}, } // CountriesTable holds the schema information for the "countries" table. CountriesTable = &schema.Table{ Name: "countries", Columns: CountriesColumns, PrimaryKey: []*schema.Column{CountriesColumns[0]}, } // FilesColumns holds the columns for the "files" table. FilesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString}, {Name: "path", Type: field.TypeString}, {Name: "type", Type: field.TypeEnum, Enums: []string{"audio", "video", "image"}}, {Name: "external_id", Type: field.TypeString, Nullable: true}, {Name: "external_info_provider", Type: field.TypeString, Nullable: true}, {Name: "results", Type: field.TypeString, Nullable: true}, {Name: "synced", Type: field.TypeBool, Default: false}, {Name: "movie_file", Type: field.TypeInt, Unique: true, Nullable: true}, } // 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_movies_file", Columns: []*schema.Column{FilesColumns[8]}, RefColumns: []*schema.Column{MoviesColumns[0]}, OnDelete: schema.SetNull, }, }, } // MoviesColumns holds the columns for the "movies" table. MoviesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "title", Type: field.TypeString}, {Name: "original_title", Type: field.TypeString, Nullable: true}, {Name: "release_date", Type: field.TypeTime, Nullable: true}, {Name: "plot", Type: field.TypeString, Nullable: true}, {Name: "duration", Type: field.TypeInt, Nullable: true}, {Name: "watched", Type: field.TypeBool, Default: false}, {Name: "movie_poster", Type: field.TypeInt, Nullable: true}, } // MoviesTable holds the schema information for the "movies" table. MoviesTable = &schema.Table{ Name: "movies", Columns: MoviesColumns, PrimaryKey: []*schema.Column{MoviesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "movies_pictures_poster", Columns: []*schema.Column{MoviesColumns[7]}, RefColumns: []*schema.Column{PicturesColumns[0]}, OnDelete: schema.SetNull, }, }, } // MovieGenresColumns holds the columns for the "movie_genres" table. MovieGenresColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString}, } // MovieGenresTable holds the schema information for the "movie_genres" table. MovieGenresTable = &schema.Table{ Name: "movie_genres", Columns: MovieGenresColumns, PrimaryKey: []*schema.Column{MovieGenresColumns[0]}, } // PicturesColumns holds the columns for the "pictures" table. PicturesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "filename", Type: field.TypeString}, {Name: "path", Type: field.TypeString}, {Name: "artist_pictures", Type: field.TypeInt, Nullable: true}, {Name: "movie_fanart", Type: field.TypeInt, Nullable: true}, } // PicturesTable holds the schema information for the "pictures" table. PicturesTable = &schema.Table{ Name: "pictures", Columns: PicturesColumns, PrimaryKey: []*schema.Column{PicturesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "pictures_artists_pictures", Columns: []*schema.Column{PicturesColumns[4]}, RefColumns: []*schema.Column{ArtistsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "pictures_movies_fanart", Columns: []*schema.Column{PicturesColumns[5]}, RefColumns: []*schema.Column{MoviesColumns[0]}, OnDelete: schema.SetNull, }, }, } // RatingsColumns holds the columns for the "ratings" table. RatingsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "origin", Type: field.TypeString}, {Name: "original_rating", Type: field.TypeString}, {Name: "normalized_rating", Type: field.TypeInt}, {Name: "movie_ratings", Type: field.TypeInt, Nullable: true}, } // RatingsTable holds the schema information for the "ratings" table. RatingsTable = &schema.Table{ Name: "ratings", Columns: RatingsColumns, PrimaryKey: []*schema.Column{RatingsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "ratings_movies_ratings", Columns: []*schema.Column{RatingsColumns[4]}, RefColumns: []*schema.Column{MoviesColumns[0]}, OnDelete: schema.SetNull, }, }, } // CountryMoviesColumns holds the columns for the "country_movies" table. CountryMoviesColumns = []*schema.Column{ {Name: "country_id", Type: field.TypeInt}, {Name: "movie_id", Type: field.TypeInt}, } // CountryMoviesTable holds the schema information for the "country_movies" table. CountryMoviesTable = &schema.Table{ Name: "country_movies", Columns: CountryMoviesColumns, PrimaryKey: []*schema.Column{CountryMoviesColumns[0], CountryMoviesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "country_movies_country_id", Columns: []*schema.Column{CountryMoviesColumns[0]}, RefColumns: []*schema.Column{CountriesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "country_movies_movie_id", Columns: []*schema.Column{CountryMoviesColumns[1]}, RefColumns: []*schema.Column{MoviesColumns[0]}, OnDelete: schema.Cascade, }, }, } // CountryArtistsColumns holds the columns for the "country_artists" table. CountryArtistsColumns = []*schema.Column{ {Name: "country_id", Type: field.TypeInt}, {Name: "artist_id", Type: field.TypeInt}, } // CountryArtistsTable holds the schema information for the "country_artists" table. CountryArtistsTable = &schema.Table{ Name: "country_artists", Columns: CountryArtistsColumns, PrimaryKey: []*schema.Column{CountryArtistsColumns[0], CountryArtistsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "country_artists_country_id", Columns: []*schema.Column{CountryArtistsColumns[0]}, RefColumns: []*schema.Column{CountriesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "country_artists_artist_id", Columns: []*schema.Column{CountryArtistsColumns[1]}, RefColumns: []*schema.Column{ArtistsColumns[0]}, OnDelete: schema.Cascade, }, }, } // MovieCastColumns holds the columns for the "movie_cast" table. MovieCastColumns = []*schema.Column{ {Name: "movie_id", Type: field.TypeInt}, {Name: "artist_id", Type: field.TypeInt}, } // MovieCastTable holds the schema information for the "movie_cast" table. MovieCastTable = &schema.Table{ Name: "movie_cast", Columns: MovieCastColumns, PrimaryKey: []*schema.Column{MovieCastColumns[0], MovieCastColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "movie_cast_movie_id", Columns: []*schema.Column{MovieCastColumns[0]}, RefColumns: []*schema.Column{MoviesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "movie_cast_artist_id", Columns: []*schema.Column{MovieCastColumns[1]}, RefColumns: []*schema.Column{ArtistsColumns[0]}, OnDelete: schema.Cascade, }, }, } // MovieDirectorsColumns holds the columns for the "movie_directors" table. MovieDirectorsColumns = []*schema.Column{ {Name: "movie_id", Type: field.TypeInt}, {Name: "artist_id", Type: field.TypeInt}, } // MovieDirectorsTable holds the schema information for the "movie_directors" table. MovieDirectorsTable = &schema.Table{ Name: "movie_directors", Columns: MovieDirectorsColumns, PrimaryKey: []*schema.Column{MovieDirectorsColumns[0], MovieDirectorsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "movie_directors_movie_id", Columns: []*schema.Column{MovieDirectorsColumns[0]}, RefColumns: []*schema.Column{MoviesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "movie_directors_artist_id", Columns: []*schema.Column{MovieDirectorsColumns[1]}, RefColumns: []*schema.Column{ArtistsColumns[0]}, OnDelete: schema.Cascade, }, }, } // MovieWritersColumns holds the columns for the "movie_writers" table. MovieWritersColumns = []*schema.Column{ {Name: "movie_id", Type: field.TypeInt}, {Name: "artist_id", Type: field.TypeInt}, } // MovieWritersTable holds the schema information for the "movie_writers" table. MovieWritersTable = &schema.Table{ Name: "movie_writers", Columns: MovieWritersColumns, PrimaryKey: []*schema.Column{MovieWritersColumns[0], MovieWritersColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "movie_writers_movie_id", Columns: []*schema.Column{MovieWritersColumns[0]}, RefColumns: []*schema.Column{MoviesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "movie_writers_artist_id", Columns: []*schema.Column{MovieWritersColumns[1]}, RefColumns: []*schema.Column{ArtistsColumns[0]}, OnDelete: schema.Cascade, }, }, } // MovieGenreMoviesColumns holds the columns for the "movie_genre_movies" table. MovieGenreMoviesColumns = []*schema.Column{ {Name: "movie_genre_id", Type: field.TypeInt}, {Name: "movie_id", Type: field.TypeInt}, } // MovieGenreMoviesTable holds the schema information for the "movie_genre_movies" table. MovieGenreMoviesTable = &schema.Table{ Name: "movie_genre_movies", Columns: MovieGenreMoviesColumns, PrimaryKey: []*schema.Column{MovieGenreMoviesColumns[0], MovieGenreMoviesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "movie_genre_movies_movie_genre_id", Columns: []*schema.Column{MovieGenreMoviesColumns[0]}, RefColumns: []*schema.Column{MovieGenresColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "movie_genre_movies_movie_id", Columns: []*schema.Column{MovieGenreMoviesColumns[1]}, RefColumns: []*schema.Column{MoviesColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ ArtistsTable, CountriesTable, FilesTable, MoviesTable, MovieGenresTable, PicturesTable, RatingsTable, CountryMoviesTable, CountryArtistsTable, MovieCastTable, MovieDirectorsTable, MovieWritersTable, MovieGenreMoviesTable, } )
Functions ¶
This section is empty.
Types ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the API for creating, migrating and dropping a schema.
Click to show internal directories.
Click to hide internal directories.