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 ( // AccountsColumns holds the columns for the "accounts" table. AccountsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "owner", Type: field.TypeString, Unique: true}, {Name: "is_private", Type: field.TypeBool, Default: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "follower", Type: field.TypeInt64, Default: 0}, {Name: "following", Type: field.TypeInt64, Default: 0}, {Name: "photo_dir", Type: field.TypeString, Nullable: true, Size: 70}, } // AccountsTable holds the schema information for the "accounts" table. AccountsTable = &schema.Table{ Name: "accounts", Columns: AccountsColumns, PrimaryKey: []*schema.Column{AccountsColumns[0]}, } // AccountNotifsColumns holds the columns for the "account_notifs" table. AccountNotifsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "account_id", Type: field.TypeInt64, Nullable: true}, {Name: "notif_type", Type: field.TypeString, Size: 255}, {Name: "notif_title", Type: field.TypeString, Nullable: true, Size: 50}, {Name: "notif_content", Type: field.TypeString, Nullable: true, Size: 255}, {Name: "notif_time", Type: field.TypeTime, Nullable: true}, {Name: "username", Type: field.TypeString, Nullable: true, Size: 255}, {Name: "created_at", Type: field.TypeTime}, } // AccountNotifsTable holds the schema information for the "account_notifs" table. AccountNotifsTable = &schema.Table{ Name: "account_notifs", Columns: AccountNotifsColumns, PrimaryKey: []*schema.Column{AccountNotifsColumns[0]}, Indexes: []*schema.Index{ { Name: "accountnotifs_created_at", Unique: false, Columns: []*schema.Column{AccountNotifsColumns[7]}, }, }, } // LikeFeaturesColumns holds the columns for the "like_features" table. LikeFeaturesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "from_account_id", Type: field.TypeInt64}, {Name: "is_like", Type: field.TypeBool, Default: false}, {Name: "post_id", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime}, } // LikeFeaturesTable holds the schema information for the "like_features" table. LikeFeaturesTable = &schema.Table{ Name: "like_features", Columns: LikeFeaturesColumns, PrimaryKey: []*schema.Column{LikeFeaturesColumns[0]}, } // PostsColumns holds the columns for the "posts" table. PostsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "owner", Type: field.TypeString}, {Name: "is_private", Type: field.TypeBool, Default: false}, {Name: "created_at", Type: field.TypeTime}, {Name: "follower", Type: field.TypeInt64, Default: 0}, {Name: "following", Type: field.TypeInt64, Default: 0}, {Name: "photo_dir", Type: field.TypeString, Nullable: true}, } // PostsTable holds the schema information for the "posts" table. PostsTable = &schema.Table{ Name: "posts", Columns: PostsColumns, PrimaryKey: []*schema.Column{PostsColumns[0]}, } // QouteRetweetFeaturesColumns holds the columns for the "qoute_retweet_features" table. QouteRetweetFeaturesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "from_account_id", Type: field.TypeInt64}, {Name: "qoute_retweet", Type: field.TypeBool, Default: false}, {Name: "qoute", Type: field.TypeString}, {Name: "post_id", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime}, } // QouteRetweetFeaturesTable holds the schema information for the "qoute_retweet_features" table. QouteRetweetFeaturesTable = &schema.Table{ Name: "qoute_retweet_features", Columns: QouteRetweetFeaturesColumns, PrimaryKey: []*schema.Column{QouteRetweetFeaturesColumns[0]}, } // RetweetFeaturesColumns holds the columns for the "retweet_features" table. RetweetFeaturesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "from_account_id", Type: field.TypeInt64}, {Name: "retweet", Type: field.TypeBool, Default: false}, {Name: "post_id", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime}, } // RetweetFeaturesTable holds the schema information for the "retweet_features" table. RetweetFeaturesTable = &schema.Table{ Name: "retweet_features", Columns: RetweetFeaturesColumns, PrimaryKey: []*schema.Column{RetweetFeaturesColumns[0]}, } // TokensColumns holds the columns for the "tokens" table. TokensColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "email", Type: field.TypeString, Unique: true, Size: 255}, {Name: "access_token", Type: field.TypeString}, {Name: "refresh_token", Type: field.TypeString}, {Name: "token_type", Type: field.TypeString, Size: 255}, {Name: "expiry", Type: field.TypeTime}, {Name: "raw", Type: field.TypeJSON}, } // TokensTable holds the schema information for the "tokens" table. TokensTable = &schema.Table{ Name: "tokens", Columns: TokensColumns, PrimaryKey: []*schema.Column{TokensColumns[0]}, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "username", Type: field.TypeString, Unique: true}, {Name: "hashed_password", Type: field.TypeString, Nullable: true}, {Name: "email", Type: field.TypeString, Unique: true}, {Name: "full_name", Type: field.TypeString}, {Name: "password_changed_at", Type: field.TypeTime, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, } // 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{ AccountsTable, AccountNotifsTable, LikeFeaturesTable, PostsTable, QouteRetweetFeaturesTable, RetweetFeaturesTable, TokensTable, UsersTable, } )
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.