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 ( // AttachmentsColumns holds the columns for the "attachments" table. AttachmentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "is_remote", Type: field.TypeBool}, {Name: "uri", Type: field.TypeString}, {Name: "extensions", Type: field.TypeJSON}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "description", Type: field.TypeString, Size: 384}, {Name: "sha256", Type: field.TypeBytes}, {Name: "size", Type: field.TypeInt}, {Name: "blurhash", Type: field.TypeString, Nullable: true}, {Name: "height", Type: field.TypeInt, Nullable: true}, {Name: "width", Type: field.TypeInt, Nullable: true}, {Name: "fps", Type: field.TypeInt, Nullable: true}, {Name: "mime_type", Type: field.TypeString}, {Name: "attachment_author", Type: field.TypeUUID}, {Name: "note_attachments", Type: field.TypeUUID, Nullable: true}, } // AttachmentsTable holds the schema information for the "attachments" table. AttachmentsTable = &schema.Table{ Name: "attachments", Columns: AttachmentsColumns, PrimaryKey: []*schema.Column{AttachmentsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "attachments_users_author", Columns: []*schema.Column{AttachmentsColumns[14]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "attachments_notes_attachments", Columns: []*schema.Column{AttachmentsColumns[15]}, RefColumns: []*schema.Column{NotesColumns[0]}, OnDelete: schema.SetNull, }, }, } // FollowsColumns holds the columns for the "follows" table. FollowsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "is_remote", Type: field.TypeBool}, {Name: "uri", Type: field.TypeString}, {Name: "extensions", Type: field.TypeJSON}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "accepted"}, Default: "pending"}, {Name: "follow_follower", Type: field.TypeUUID}, {Name: "follow_followee", Type: field.TypeUUID}, } // FollowsTable holds the schema information for the "follows" table. FollowsTable = &schema.Table{ Name: "follows", Columns: FollowsColumns, PrimaryKey: []*schema.Column{FollowsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "follows_users_follower", Columns: []*schema.Column{FollowsColumns[7]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "follows_users_followee", Columns: []*schema.Column{FollowsColumns[8]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "follow_follow_follower_follow_followee", Unique: true, Columns: []*schema.Column{FollowsColumns[7], FollowsColumns[8]}, }, }, } // ImagesColumns holds the columns for the "images" table. ImagesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "url", Type: field.TypeString}, {Name: "mime_type", Type: field.TypeString}, } // ImagesTable holds the schema information for the "images" table. ImagesTable = &schema.Table{ Name: "images", Columns: ImagesColumns, PrimaryKey: []*schema.Column{ImagesColumns[0]}, } // InstanceMetadataColumns holds the columns for the "instance_metadata" table. InstanceMetadataColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "is_remote", Type: field.TypeBool}, {Name: "uri", Type: field.TypeString}, {Name: "extensions", Type: field.TypeJSON}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "host", Type: field.TypeString, Unique: true}, {Name: "public_key", Type: field.TypeBytes}, {Name: "public_key_algorithm", Type: field.TypeString}, {Name: "private_key", Type: field.TypeBytes, Nullable: true}, {Name: "software_name", Type: field.TypeString}, {Name: "software_version", Type: field.TypeString}, {Name: "shared_inbox_uri", Type: field.TypeString}, {Name: "moderators_uri", Type: field.TypeString, Nullable: true}, {Name: "admins_uri", Type: field.TypeString, Nullable: true}, {Name: "logo_endpoint", Type: field.TypeString, Nullable: true}, {Name: "logo_mime_type", Type: field.TypeString, Nullable: true}, {Name: "banner_endpoint", Type: field.TypeString, Nullable: true}, {Name: "banner_mime_type", Type: field.TypeString, Nullable: true}, {Name: "supported_versions", Type: field.TypeJSON}, {Name: "supported_extensions", Type: field.TypeJSON}, } // InstanceMetadataTable holds the schema information for the "instance_metadata" table. InstanceMetadataTable = &schema.Table{ Name: "instance_metadata", Columns: InstanceMetadataColumns, PrimaryKey: []*schema.Column{InstanceMetadataColumns[0]}, } // NotesColumns holds the columns for the "notes" table. NotesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "is_remote", Type: field.TypeBool}, {Name: "uri", Type: field.TypeString}, {Name: "extensions", Type: field.TypeJSON}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "subject", Type: field.TypeString, Nullable: true, Size: 384}, {Name: "content", Type: field.TypeString}, {Name: "is_sensitive", Type: field.TypeBool, Default: false}, {Name: "visibility", Type: field.TypeEnum, Enums: []string{"public", "unlisted", "followers", "direct"}, Default: "public"}, {Name: "note_author", Type: field.TypeUUID}, } // NotesTable holds the schema information for the "notes" table. NotesTable = &schema.Table{ Name: "notes", Columns: NotesColumns, PrimaryKey: []*schema.Column{NotesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "notes_users_author", Columns: []*schema.Column{NotesColumns[10]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, }, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "is_remote", Type: field.TypeBool}, {Name: "uri", Type: field.TypeString}, {Name: "extensions", Type: field.TypeJSON}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "username", Type: field.TypeString, Unique: true, Size: 32}, {Name: "password_hash", Type: field.TypeBytes, Nullable: true}, {Name: "display_name", Type: field.TypeString, Nullable: true, Size: 256}, {Name: "biography", Type: field.TypeString, Nullable: true}, {Name: "public_key", Type: field.TypeBytes}, {Name: "public_key_actor", Type: field.TypeString}, {Name: "public_key_algorithm", Type: field.TypeString}, {Name: "private_key", Type: field.TypeBytes, Nullable: true}, {Name: "indexable", Type: field.TypeBool, Default: true}, {Name: "privacy_level", Type: field.TypeEnum, Enums: []string{"public", "restricted", "private"}, Default: "public"}, {Name: "fields", Type: field.TypeJSON}, {Name: "inbox", Type: field.TypeString}, {Name: "featured", Type: field.TypeString}, {Name: "followers", Type: field.TypeString}, {Name: "following", Type: field.TypeString}, {Name: "outbox", Type: field.TypeString}, {Name: "user_avatar_image", Type: field.TypeInt, Nullable: true}, {Name: "user_header_image", Type: field.TypeInt, Nullable: true}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ Name: "users", Columns: UsersColumns, PrimaryKey: []*schema.Column{UsersColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "users_images_avatarImage", Columns: []*schema.Column{UsersColumns[22]}, RefColumns: []*schema.Column{ImagesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "users_images_headerImage", Columns: []*schema.Column{UsersColumns[23]}, RefColumns: []*schema.Column{ImagesColumns[0]}, OnDelete: schema.SetNull, }, }, } // InstanceMetadataUsersColumns holds the columns for the "instance_metadata_users" table. InstanceMetadataUsersColumns = []*schema.Column{ {Name: "instance_metadata_id", Type: field.TypeUUID}, {Name: "user_id", Type: field.TypeUUID}, } // InstanceMetadataUsersTable holds the schema information for the "instance_metadata_users" table. InstanceMetadataUsersTable = &schema.Table{ Name: "instance_metadata_users", Columns: InstanceMetadataUsersColumns, PrimaryKey: []*schema.Column{InstanceMetadataUsersColumns[0], InstanceMetadataUsersColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "instance_metadata_users_instance_metadata_id", Columns: []*schema.Column{InstanceMetadataUsersColumns[0]}, RefColumns: []*schema.Column{InstanceMetadataColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "instance_metadata_users_user_id", Columns: []*schema.Column{InstanceMetadataUsersColumns[1]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // InstanceMetadataModeratorsColumns holds the columns for the "instance_metadata_moderators" table. InstanceMetadataModeratorsColumns = []*schema.Column{ {Name: "instance_metadata_id", Type: field.TypeUUID}, {Name: "user_id", Type: field.TypeUUID}, } // InstanceMetadataModeratorsTable holds the schema information for the "instance_metadata_moderators" table. InstanceMetadataModeratorsTable = &schema.Table{ Name: "instance_metadata_moderators", Columns: InstanceMetadataModeratorsColumns, PrimaryKey: []*schema.Column{InstanceMetadataModeratorsColumns[0], InstanceMetadataModeratorsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "instance_metadata_moderators_instance_metadata_id", Columns: []*schema.Column{InstanceMetadataModeratorsColumns[0]}, RefColumns: []*schema.Column{InstanceMetadataColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "instance_metadata_moderators_user_id", Columns: []*schema.Column{InstanceMetadataModeratorsColumns[1]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // InstanceMetadataAdminsColumns holds the columns for the "instance_metadata_admins" table. InstanceMetadataAdminsColumns = []*schema.Column{ {Name: "instance_metadata_id", Type: field.TypeUUID}, {Name: "user_id", Type: field.TypeUUID}, } // InstanceMetadataAdminsTable holds the schema information for the "instance_metadata_admins" table. InstanceMetadataAdminsTable = &schema.Table{ Name: "instance_metadata_admins", Columns: InstanceMetadataAdminsColumns, PrimaryKey: []*schema.Column{InstanceMetadataAdminsColumns[0], InstanceMetadataAdminsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "instance_metadata_admins_instance_metadata_id", Columns: []*schema.Column{InstanceMetadataAdminsColumns[0]}, RefColumns: []*schema.Column{InstanceMetadataColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "instance_metadata_admins_user_id", Columns: []*schema.Column{InstanceMetadataAdminsColumns[1]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // NoteMentionsColumns holds the columns for the "note_mentions" table. NoteMentionsColumns = []*schema.Column{ {Name: "note_id", Type: field.TypeUUID}, {Name: "user_id", Type: field.TypeUUID}, } // NoteMentionsTable holds the schema information for the "note_mentions" table. NoteMentionsTable = &schema.Table{ Name: "note_mentions", Columns: NoteMentionsColumns, PrimaryKey: []*schema.Column{NoteMentionsColumns[0], NoteMentionsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "note_mentions_note_id", Columns: []*schema.Column{NoteMentionsColumns[0]}, RefColumns: []*schema.Column{NotesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "note_mentions_user_id", Columns: []*schema.Column{NoteMentionsColumns[1]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AttachmentsTable, FollowsTable, ImagesTable, InstanceMetadataTable, NotesTable, UsersTable, InstanceMetadataUsersTable, InstanceMetadataModeratorsTable, InstanceMetadataAdminsTable, NoteMentionsTable, } )
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.