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 ( // IssuesColumns holds the columns for the "issues" table. IssuesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "node_id", Type: field.TypeString}, {Name: "url", Type: field.TypeString}, {Name: "repository_url", Type: field.TypeString}, {Name: "labels_url", Type: field.TypeString}, {Name: "comments_url", Type: field.TypeString}, {Name: "events_url", Type: field.TypeString}, {Name: "html_url", Type: field.TypeString}, {Name: "number", Type: field.TypeInt64}, {Name: "state", Type: field.TypeString}, {Name: "state_reason", Type: field.TypeEnum, Nullable: true, Enums: []string{"completed", "reopened", "not_planned"}}, {Name: "title", Type: field.TypeString}, {Name: "body", Type: field.TypeString, Nullable: true}, {Name: "locked", Type: field.TypeBool}, {Name: "active_lock_reason", Type: field.TypeString, Nullable: true}, {Name: "closed_at", Type: field.TypeTime, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "draft", Type: field.TypeBool}, {Name: "author_association", Type: field.TypeEnum, Enums: []string{"COLLABORATOR", "CONTRIBUTOR", "FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "MANNEQUIN", "MEMBER", "NONE", "OWNER"}}, {Name: "reactions", Type: field.TypeJSON}, {Name: "issue_closed_by", Type: field.TypeInt64, Nullable: true}, {Name: "repository_issues", Type: field.TypeInt64}, {Name: "user_issues_created", Type: field.TypeInt64, Nullable: true}, } // IssuesTable holds the schema information for the "issues" table. IssuesTable = &schema.Table{ Name: "issues", Columns: IssuesColumns, PrimaryKey: []*schema.Column{IssuesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "issues_users_closed_by", Columns: []*schema.Column{IssuesColumns[21]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "issues_repositories_issues", Columns: []*schema.Column{IssuesColumns[22]}, RefColumns: []*schema.Column{RepositoriesColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "issues_users_issues_created", Columns: []*schema.Column{IssuesColumns[23]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, } // IssueCommentsColumns holds the columns for the "issue_comments" table. IssueCommentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "node_id", Type: field.TypeString}, {Name: "url", Type: field.TypeString}, {Name: "body", Type: field.TypeString}, {Name: "html_url", Type: field.TypeString}, {Name: "created_at", Type: field.TypeString}, {Name: "updated_at", Type: field.TypeString}, {Name: "issue_url", Type: field.TypeString}, {Name: "author_association", Type: field.TypeEnum, Enums: []string{"COLLABORATOR", "CONTRIBUTOR", "FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "MANNEQUIN", "MEMBER", "NONE", "OWNER"}}, {Name: "reactions", Type: field.TypeJSON}, {Name: "issue_comments", Type: field.TypeInt64, Nullable: true}, {Name: "user_comments_created", Type: field.TypeInt64, Nullable: true}, } // IssueCommentsTable holds the schema information for the "issue_comments" table. IssueCommentsTable = &schema.Table{ Name: "issue_comments", Columns: IssueCommentsColumns, PrimaryKey: []*schema.Column{IssueCommentsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "issue_comments_issues_comments", Columns: []*schema.Column{IssueCommentsColumns[10]}, RefColumns: []*schema.Column{IssuesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "issue_comments_users_comments_created", Columns: []*schema.Column{IssueCommentsColumns[11]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, } // RepositoriesColumns holds the columns for the "repositories" table. RepositoriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "node_id", Type: field.TypeString}, {Name: "name", Type: field.TypeString}, {Name: "full_name", Type: field.TypeString, Unique: true}, {Name: "private", Type: field.TypeBool}, {Name: "html_url", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "fork", Type: field.TypeBool}, {Name: "url", Type: field.TypeString}, {Name: "archive_url", Type: field.TypeString}, {Name: "assignees_url", Type: field.TypeString}, {Name: "blobs_url", Type: field.TypeString}, {Name: "branches_url", Type: field.TypeString}, {Name: "collaborators_url", Type: field.TypeString}, {Name: "comments_url", Type: field.TypeString}, {Name: "commits_url", Type: field.TypeString}, {Name: "compare_url", Type: field.TypeString}, {Name: "contents_url", Type: field.TypeString}, {Name: "contributors_url", Type: field.TypeString}, {Name: "deployments_url", Type: field.TypeString}, {Name: "downloads_url", Type: field.TypeString}, {Name: "events_url", Type: field.TypeString}, {Name: "forks_url", Type: field.TypeString}, {Name: "git_commits_url", Type: field.TypeString}, {Name: "git_refs_url", Type: field.TypeString}, {Name: "git_tags_url", Type: field.TypeString}, {Name: "git_url", Type: field.TypeString}, {Name: "issue_comment_url", Type: field.TypeString}, {Name: "issue_events_url", Type: field.TypeString}, {Name: "issues_url", Type: field.TypeString}, {Name: "keys_url", Type: field.TypeString}, {Name: "labels_url", Type: field.TypeString}, {Name: "languages_url", Type: field.TypeString}, {Name: "merges_url", Type: field.TypeString}, {Name: "milestones_url", Type: field.TypeString}, {Name: "notifications_url", Type: field.TypeString}, {Name: "pulls_url", Type: field.TypeString}, {Name: "releases_url", Type: field.TypeString}, {Name: "ssh_url", Type: field.TypeString}, {Name: "stargazers_url", Type: field.TypeString}, {Name: "statuses_url", Type: field.TypeString}, {Name: "subscribers_url", Type: field.TypeString}, {Name: "subscription_url", Type: field.TypeString}, {Name: "tags_url", Type: field.TypeString}, {Name: "teams_url", Type: field.TypeString}, {Name: "trees_url", Type: field.TypeString}, {Name: "clone_url", Type: field.TypeString}, {Name: "mirror_url", Type: field.TypeString, Nullable: true}, {Name: "hooks_url", Type: field.TypeString}, {Name: "svn_url", Type: field.TypeString}, {Name: "homepage", Type: field.TypeString, Nullable: true}, {Name: "language", Type: field.TypeString, Nullable: true}, {Name: "forks_count", Type: field.TypeInt64}, {Name: "stargazers_count", Type: field.TypeInt64}, {Name: "watchers_count", Type: field.TypeInt64}, {Name: "size", Type: field.TypeInt64}, {Name: "default_branch", Type: field.TypeString}, {Name: "open_issues_count", Type: field.TypeInt64}, {Name: "is_template", Type: field.TypeBool}, {Name: "topics", Type: field.TypeJSON}, {Name: "has_issues_enabled", Type: field.TypeBool}, {Name: "has_projects", Type: field.TypeBool}, {Name: "has_wiki", Type: field.TypeBool}, {Name: "has_pages", Type: field.TypeBool}, {Name: "has_downloads", Type: field.TypeBool}, {Name: "has_discussions", Type: field.TypeBool}, {Name: "archived", Type: field.TypeBool}, {Name: "disabled", Type: field.TypeBool}, {Name: "visibility", Type: field.TypeEnum, Nullable: true, Enums: []string{"public", "private", "internal"}}, {Name: "pushed_at", Type: field.TypeTime}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "subscribers_count", Type: field.TypeInt64}, {Name: "network_count", Type: field.TypeInt64}, {Name: "forks", Type: field.TypeInt64}, {Name: "open_issues", Type: field.TypeInt64}, {Name: "watchers", Type: field.TypeInt64}, {Name: "license", Type: field.TypeJSON, Nullable: true}, {Name: "user_repositories", Type: field.TypeInt64, Nullable: true}, } // RepositoriesTable holds the schema information for the "repositories" table. RepositoriesTable = &schema.Table{ Name: "repositories", Columns: RepositoriesColumns, PrimaryKey: []*schema.Column{RepositoriesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "repositories_users_repositories", Columns: []*schema.Column{RepositoriesColumns[78]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "login", Type: field.TypeString, Unique: true}, {Name: "node_id", Type: field.TypeString}, {Name: "avatar_url", Type: field.TypeString}, {Name: "gravatar_id", Type: field.TypeString, Nullable: true}, {Name: "url", Type: field.TypeString}, {Name: "html_url", Type: field.TypeString}, {Name: "followers_url", Type: field.TypeString}, {Name: "following_url", Type: field.TypeString}, {Name: "gists_url", Type: field.TypeString}, {Name: "starred_url", Type: field.TypeString}, {Name: "subscriptions_url", Type: field.TypeString}, {Name: "organizations_url", Type: field.TypeString}, {Name: "repos_url", Type: field.TypeString}, {Name: "events_url", Type: field.TypeString}, {Name: "received_events_url", Type: field.TypeString}, {Name: "type", Type: field.TypeString}, {Name: "site_admin", Type: field.TypeBool}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "company", Type: field.TypeString, Nullable: true}, {Name: "blog", Type: field.TypeString, Nullable: true}, {Name: "location", Type: field.TypeString, Nullable: true}, {Name: "email", Type: field.TypeString, Nullable: true}, {Name: "hireable", Type: field.TypeBool, Nullable: true}, {Name: "bio", Type: field.TypeString, Nullable: true}, {Name: "public_repos", Type: field.TypeInt64}, {Name: "public_gists", Type: field.TypeInt64}, {Name: "followers", Type: field.TypeInt64}, {Name: "following", Type: field.TypeInt64}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_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]}, } // IssueAssigneesColumns holds the columns for the "issue_assignees" table. IssueAssigneesColumns = []*schema.Column{ {Name: "issue_id", Type: field.TypeInt64}, {Name: "user_id", Type: field.TypeInt64}, } // IssueAssigneesTable holds the schema information for the "issue_assignees" table. IssueAssigneesTable = &schema.Table{ Name: "issue_assignees", Columns: IssueAssigneesColumns, PrimaryKey: []*schema.Column{IssueAssigneesColumns[0], IssueAssigneesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "issue_assignees_issue_id", Columns: []*schema.Column{IssueAssigneesColumns[0]}, RefColumns: []*schema.Column{IssuesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "issue_assignees_user_id", Columns: []*schema.Column{IssueAssigneesColumns[1]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ IssuesTable, IssueCommentsTable, RepositoriesTable, UsersTable, IssueAssigneesTable, } )
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.