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 ( // AccessTokensColumns holds the columns for the "access_tokens" table. AccessTokensColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "token", Type: field.TypeString, Nullable: true}, {Name: "expiry", Type: field.TypeTime, Nullable: true}, {Name: "refresh_token_id", Type: field.TypeUint}, {Name: "user_id", Type: field.TypeUUID}, } // AccessTokensTable holds the schema information for the "access_tokens" table. AccessTokensTable = &schema.Table{ Name: "access_tokens", Columns: AccessTokensColumns, PrimaryKey: []*schema.Column{AccessTokensColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "access_tokens_refresh_tokens_access_tokens", Columns: []*schema.Column{AccessTokensColumns[5]}, RefColumns: []*schema.Column{RefreshTokensColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "access_tokens_users_access_tokens", Columns: []*schema.Column{AccessTokensColumns[6]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, }, } // LikeVideosColumns holds the columns for the "like_videos" table. LikeVideosColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "user_id", Type: field.TypeUUID}, {Name: "video_id", Type: field.TypeString}, } // LikeVideosTable holds the schema information for the "like_videos" table. LikeVideosTable = &schema.Table{ Name: "like_videos", Columns: LikeVideosColumns, PrimaryKey: []*schema.Column{LikeVideosColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "like_videos_users_like_videos", Columns: []*schema.Column{LikeVideosColumns[3]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "like_videos_videos_like_videos", Columns: []*schema.Column{LikeVideosColumns[4]}, RefColumns: []*schema.Column{VideosColumns[0]}, OnDelete: schema.NoAction, }, }, } // RefreshTokensColumns holds the columns for the "refresh_tokens" table. RefreshTokensColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "token", Type: field.TypeString, Nullable: true}, {Name: "expiry", Type: field.TypeTime, Nullable: true}, {Name: "user_agent", Type: field.TypeString, Nullable: true}, {Name: "ip_address", Type: field.TypeString, Nullable: true}, {Name: "user_id", Type: field.TypeUUID}, } // RefreshTokensTable holds the schema information for the "refresh_tokens" table. RefreshTokensTable = &schema.Table{ Name: "refresh_tokens", Columns: RefreshTokensColumns, PrimaryKey: []*schema.Column{RefreshTokensColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "refresh_tokens_users_refresh_tokens", Columns: []*schema.Column{RefreshTokensColumns[7]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, }, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "email", Type: field.TypeString, Unique: true}, {Name: "password", Type: field.TypeString}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ Name: "users", Columns: UsersColumns, PrimaryKey: []*schema.Column{UsersColumns[0]}, } // VideosColumns holds the columns for the "videos" table. VideosColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "title", Type: field.TypeString}, {Name: "description", Type: field.TypeString}, {Name: "upload_date", Type: field.TypeTime}, {Name: "uploader", Type: field.TypeString}, {Name: "uploader_url", Type: field.TypeString}, {Name: "thumbnail_url", Type: field.TypeString}, } // VideosTable holds the schema information for the "videos" table. VideosTable = &schema.Table{ Name: "videos", Columns: VideosColumns, PrimaryKey: []*schema.Column{VideosColumns[0]}, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AccessTokensTable, LikeVideosTable, RefreshTokensTable, UsersTable, VideosTable, } )
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.