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: "comments_count", Type: field.TypeInt64}, {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", "OWNER", "NONE"}}, {Name: "reactions", Type: field.TypeJSON}, {Name: "repository_issues", Type: field.TypeInt64}, {Name: "user_issues_created", Type: field.TypeInt64, Nullable: true}, {Name: "user_issues_closed", 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_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, }, { Symbol: "issues_users_issues_closed", Columns: []*schema.Column{IssuesColumns[24]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "issue_number_repository_issues", Unique: true, Columns: []*schema.Column{IssuesColumns[8], IssuesColumns[22]}, }, }, } // 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", "OWNER", "NONE"}}, {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, }, }, } // PullRequestsColumns holds the columns for the "pull_requests" table. PullRequestsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "url", Type: field.TypeString}, {Name: "node_id", Type: field.TypeString}, {Name: "html_url", Type: field.TypeString}, {Name: "diff_url", Type: field.TypeString}, {Name: "patch_url", Type: field.TypeString}, {Name: "issue_url", Type: field.TypeString}, {Name: "commits_url", Type: field.TypeString}, {Name: "review_comments_url", Type: field.TypeString}, {Name: "review_comment_url", Type: field.TypeString}, {Name: "comments_url", Type: field.TypeString}, {Name: "statuses_url", Type: field.TypeString}, {Name: "number", Type: field.TypeInt64}, {Name: "state", Type: field.TypeEnum, Enums: []string{"open", "closed"}}, {Name: "locked", Type: field.TypeBool}, {Name: "title", Type: field.TypeString}, {Name: "body", Type: field.TypeString, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "closed_at", Type: field.TypeTime, Nullable: true}, {Name: "merged_at", Type: field.TypeTime, Nullable: true}, {Name: "merge_commit_sha", Type: field.TypeString, Nullable: true}, {Name: "head", Type: field.TypeJSON}, {Name: "base", Type: field.TypeJSON}, {Name: "draft", Type: field.TypeBool, Nullable: true}, {Name: "author_association", Type: field.TypeEnum, Enums: []string{"COLLABORATOR", "CONTRIBUTOR", "FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "MANNEQUIN", "MEMBER", "OWNER", "NONE"}}, {Name: "issue_pull_request", Type: field.TypeInt64, Unique: true}, {Name: "repository_pull_requests", Type: field.TypeInt64}, {Name: "user_prs_created", Type: field.TypeInt64, Nullable: true}, } // PullRequestsTable holds the schema information for the "pull_requests" table. PullRequestsTable = &schema.Table{ Name: "pull_requests", Columns: PullRequestsColumns, PrimaryKey: []*schema.Column{PullRequestsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "pull_requests_issues_pull_request", Columns: []*schema.Column{PullRequestsColumns[26]}, RefColumns: []*schema.Column{IssuesColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "pull_requests_repositories_pull_requests", Columns: []*schema.Column{PullRequestsColumns[27]}, RefColumns: []*schema.Column{RepositoriesColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "pull_requests_users_prs_created", Columns: []*schema.Column{PullRequestsColumns[28]}, 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, }, }, } // TimelineEventsColumns holds the columns for the "timeline_events" table. TimelineEventsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "numeric_id", Type: field.TypeInt64}, {Name: "node_id", Type: field.TypeString, Unique: true}, {Name: "url", Type: field.TypeString}, {Name: "event", Type: field.TypeString}, {Name: "commit_id", Type: field.TypeString, Nullable: true}, {Name: "commit_url", Type: field.TypeString, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "data", Type: field.TypeJSON}, {Name: "issue_timeline", Type: field.TypeInt64, Nullable: true}, {Name: "timeline_event_actor", Type: field.TypeInt64, Nullable: true}, } // TimelineEventsTable holds the schema information for the "timeline_events" table. TimelineEventsTable = &schema.Table{ Name: "timeline_events", Columns: TimelineEventsColumns, PrimaryKey: []*schema.Column{TimelineEventsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "timeline_events_issues_timeline", Columns: []*schema.Column{TimelineEventsColumns[9]}, RefColumns: []*schema.Column{IssuesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "timeline_events_users_actor", Columns: []*schema.Column{TimelineEventsColumns[10]}, 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, }, }, } // PullRequestAssigneesColumns holds the columns for the "pull_request_assignees" table. PullRequestAssigneesColumns = []*schema.Column{ {Name: "pull_request_id", Type: field.TypeInt64}, {Name: "user_id", Type: field.TypeInt64}, } // PullRequestAssigneesTable holds the schema information for the "pull_request_assignees" table. PullRequestAssigneesTable = &schema.Table{ Name: "pull_request_assignees", Columns: PullRequestAssigneesColumns, PrimaryKey: []*schema.Column{PullRequestAssigneesColumns[0], PullRequestAssigneesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "pull_request_assignees_pull_request_id", Columns: []*schema.Column{PullRequestAssigneesColumns[0]}, RefColumns: []*schema.Column{PullRequestsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "pull_request_assignees_user_id", Columns: []*schema.Column{PullRequestAssigneesColumns[1]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // PullRequestRequestedReviewersColumns holds the columns for the "pull_request_requested_reviewers" table. PullRequestRequestedReviewersColumns = []*schema.Column{ {Name: "pull_request_id", Type: field.TypeInt64}, {Name: "user_id", Type: field.TypeInt64}, } // PullRequestRequestedReviewersTable holds the schema information for the "pull_request_requested_reviewers" table. PullRequestRequestedReviewersTable = &schema.Table{ Name: "pull_request_requested_reviewers", Columns: PullRequestRequestedReviewersColumns, PrimaryKey: []*schema.Column{PullRequestRequestedReviewersColumns[0], PullRequestRequestedReviewersColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "pull_request_requested_reviewers_pull_request_id", Columns: []*schema.Column{PullRequestRequestedReviewersColumns[0]}, RefColumns: []*schema.Column{PullRequestsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "pull_request_requested_reviewers_user_id", Columns: []*schema.Column{PullRequestRequestedReviewersColumns[1]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ IssuesTable, IssueCommentsTable, PullRequestsTable, RepositoriesTable, TimelineEventsTable, UsersTable, IssueAssigneesTable, PullRequestAssigneesTable, PullRequestRequestedReviewersTable, } )
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.