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 ( // BooksColumns holds the columns for the "books" table. BooksColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "title", Type: field.TypeString}, {Name: "description", Type: field.TypeString}, {Name: "goodreads_id", Type: field.TypeString}, {Name: "google_volume_id", Type: field.TypeString}, {Name: "isbn_10", Type: field.TypeString}, {Name: "isbn_13", Type: field.TypeString}, } // BooksTable holds the schema information for the "books" table. BooksTable = &schema.Table{ Name: "books", Columns: BooksColumns, PrimaryKey: []*schema.Column{BooksColumns[0]}, } // BookAuthorsColumns holds the columns for the "book_authors" table. BookAuthorsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "full_name", Type: field.TypeString}, } // BookAuthorsTable holds the schema information for the "book_authors" table. BookAuthorsTable = &schema.Table{ Name: "book_authors", Columns: BookAuthorsColumns, PrimaryKey: []*schema.Column{BookAuthorsColumns[0]}, } // DiscordMessagesColumns holds the columns for the "discord_messages" table. DiscordMessagesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "raw", Type: field.TypeJSON}, } // DiscordMessagesTable holds the schema information for the "discord_messages" table. DiscordMessagesTable = &schema.Table{ Name: "discord_messages", Columns: DiscordMessagesColumns, PrimaryKey: []*schema.Column{DiscordMessagesColumns[0]}, } // DiscordUsersColumns holds the columns for the "discord_users" table. DiscordUsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "discordid", Type: field.TypeString, Default: "unknown"}, {Name: "username", Type: field.TypeString}, } // DiscordUsersTable holds the schema information for the "discord_users" table. DiscordUsersTable = &schema.Table{ Name: "discord_users", Columns: DiscordUsersColumns, PrimaryKey: []*schema.Column{DiscordUsersColumns[0]}, } // BookAuthorBooksColumns holds the columns for the "book_author_books" table. BookAuthorBooksColumns = []*schema.Column{ {Name: "book_author_id", Type: field.TypeUUID}, {Name: "book_id", Type: field.TypeUUID}, } // BookAuthorBooksTable holds the schema information for the "book_author_books" table. BookAuthorBooksTable = &schema.Table{ Name: "book_author_books", Columns: BookAuthorBooksColumns, PrimaryKey: []*schema.Column{BookAuthorBooksColumns[0], BookAuthorBooksColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "book_author_books_book_author_id", Columns: []*schema.Column{BookAuthorBooksColumns[0]}, RefColumns: []*schema.Column{BookAuthorsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "book_author_books_book_id", Columns: []*schema.Column{BookAuthorBooksColumns[1]}, RefColumns: []*schema.Column{BooksColumns[0]}, OnDelete: schema.Cascade, }, }, } // DiscordUserDiscordMessagesColumns holds the columns for the "discord_user_discord_messages" table. DiscordUserDiscordMessagesColumns = []*schema.Column{ {Name: "discord_user_id", Type: field.TypeUUID}, {Name: "discord_message_id", Type: field.TypeString}, } // DiscordUserDiscordMessagesTable holds the schema information for the "discord_user_discord_messages" table. DiscordUserDiscordMessagesTable = &schema.Table{ Name: "discord_user_discord_messages", Columns: DiscordUserDiscordMessagesColumns, PrimaryKey: []*schema.Column{DiscordUserDiscordMessagesColumns[0], DiscordUserDiscordMessagesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "discord_user_discord_messages_discord_user_id", Columns: []*schema.Column{DiscordUserDiscordMessagesColumns[0]}, RefColumns: []*schema.Column{DiscordUsersColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "discord_user_discord_messages_discord_message_id", Columns: []*schema.Column{DiscordUserDiscordMessagesColumns[1]}, RefColumns: []*schema.Column{DiscordMessagesColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ BooksTable, BookAuthorsTable, DiscordMessagesTable, DiscordUsersTable, BookAuthorBooksTable, DiscordUserDiscordMessagesTable, } )
Functions ¶
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.