[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
64
backend/ent/migrate/migrate.go
Normal file
64
backend/ent/migrate/migrate.go
Normal file
|
@ -0,0 +1,64 @@
|
|||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
// Schema is the API for creating, migrating and dropping a schema.
|
||||
type Schema struct {
|
||||
drv dialect.Driver
|
||||
}
|
||||
|
||||
// NewSchema creates a new schema client.
|
||||
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
|
||||
|
||||
// Create creates all schema resources.
|
||||
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
|
||||
return Create(ctx, s, Tables, opts...)
|
||||
}
|
||||
|
||||
// Create creates all table resources using the given schema driver.
|
||||
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
|
||||
migrate, err := schema.NewMigrate(s.drv, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ent/migrate: %w", err)
|
||||
}
|
||||
return migrate.Create(ctx, tables...)
|
||||
}
|
||||
|
||||
// WriteTo writes the schema changes to w instead of running them against the database.
|
||||
//
|
||||
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
|
||||
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
|
||||
}
|
479
backend/ent/migrate/schema.go
Normal file
479
backend/ent/migrate/schema.go
Normal file
|
@ -0,0 +1,479 @@
|
|||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
var (
|
||||
// CategoriesColumns holds the columns for the "categories" table.
|
||||
CategoriesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
}
|
||||
// CategoriesTable holds the schema information for the "categories" table.
|
||||
CategoriesTable = &schema.Table{
|
||||
Name: "categories",
|
||||
Columns: CategoriesColumns,
|
||||
PrimaryKey: []*schema.Column{CategoriesColumns[0]},
|
||||
}
|
||||
// CategoryContentsColumns holds the columns for the "category_contents" table.
|
||||
CategoryContentsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "language_code", Type: field.TypeEnum, Enums: []string{"en", "zh-Hans", "zh-Hant"}},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true},
|
||||
{Name: "slug", Type: field.TypeString},
|
||||
{Name: "category_contents", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// CategoryContentsTable holds the schema information for the "category_contents" table.
|
||||
CategoryContentsTable = &schema.Table{
|
||||
Name: "category_contents",
|
||||
Columns: CategoryContentsColumns,
|
||||
PrimaryKey: []*schema.Column{CategoryContentsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "category_contents_categories_contents",
|
||||
Columns: []*schema.Column{CategoryContentsColumns[5]},
|
||||
RefColumns: []*schema.Column{CategoriesColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "categorycontent_language_code_slug",
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{CategoryContentsColumns[1], CategoryContentsColumns[4]},
|
||||
},
|
||||
{
|
||||
Name: "categorycontent_language_code_category_contents",
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{CategoryContentsColumns[1], CategoryContentsColumns[5]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// ContributorsColumns holds the columns for the "contributors" table.
|
||||
ContributorsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "avatar_url", Type: field.TypeString, Nullable: true},
|
||||
{Name: "bio", Type: field.TypeString, Nullable: true, Size: 2147483647},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "user_contributors", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// ContributorsTable holds the schema information for the "contributors" table.
|
||||
ContributorsTable = &schema.Table{
|
||||
Name: "contributors",
|
||||
Columns: ContributorsColumns,
|
||||
PrimaryKey: []*schema.Column{ContributorsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "contributors_users_contributors",
|
||||
Columns: []*schema.Column{ContributorsColumns[6]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
}
|
||||
// ContributorRolesColumns holds the columns for the "contributor_roles" table.
|
||||
ContributorRolesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString, Unique: true},
|
||||
}
|
||||
// ContributorRolesTable holds the schema information for the "contributor_roles" table.
|
||||
ContributorRolesTable = &schema.Table{
|
||||
Name: "contributor_roles",
|
||||
Columns: ContributorRolesColumns,
|
||||
PrimaryKey: []*schema.Column{ContributorRolesColumns[0]},
|
||||
}
|
||||
// ContributorSocialLinksColumns holds the columns for the "contributor_social_links" table.
|
||||
ContributorSocialLinksColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "type", Type: field.TypeEnum, Enums: []string{"twitter", "facebook", "instagram", "linkedin", "github", "website"}},
|
||||
{Name: "name", Type: field.TypeString, Nullable: true},
|
||||
{Name: "value", Type: field.TypeString},
|
||||
{Name: "contributor_social_links", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// ContributorSocialLinksTable holds the schema information for the "contributor_social_links" table.
|
||||
ContributorSocialLinksTable = &schema.Table{
|
||||
Name: "contributor_social_links",
|
||||
Columns: ContributorSocialLinksColumns,
|
||||
PrimaryKey: []*schema.Column{ContributorSocialLinksColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "contributor_social_links_contributors_social_links",
|
||||
Columns: []*schema.Column{ContributorSocialLinksColumns[4]},
|
||||
RefColumns: []*schema.Column{ContributorsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
}
|
||||
// DailiesColumns holds the columns for the "dailies" table.
|
||||
DailiesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeString, Unique: true, Size: 6},
|
||||
{Name: "image_url", Type: field.TypeString},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "category_daily_items", Type: field.TypeInt},
|
||||
{Name: "daily_category_daily_items", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// DailiesTable holds the schema information for the "dailies" table.
|
||||
DailiesTable = &schema.Table{
|
||||
Name: "dailies",
|
||||
Columns: DailiesColumns,
|
||||
PrimaryKey: []*schema.Column{DailiesColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "dailies_categories_daily_items",
|
||||
Columns: []*schema.Column{DailiesColumns[4]},
|
||||
RefColumns: []*schema.Column{CategoriesColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
{
|
||||
Symbol: "dailies_daily_categories_daily_items",
|
||||
Columns: []*schema.Column{DailiesColumns[5]},
|
||||
RefColumns: []*schema.Column{DailyCategoriesColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
}
|
||||
// DailyCategoriesColumns holds the columns for the "daily_categories" table.
|
||||
DailyCategoriesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
}
|
||||
// DailyCategoriesTable holds the schema information for the "daily_categories" table.
|
||||
DailyCategoriesTable = &schema.Table{
|
||||
Name: "daily_categories",
|
||||
Columns: DailyCategoriesColumns,
|
||||
PrimaryKey: []*schema.Column{DailyCategoriesColumns[0]},
|
||||
}
|
||||
// DailyCategoryContentsColumns holds the columns for the "daily_category_contents" table.
|
||||
DailyCategoryContentsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "language_code", Type: field.TypeEnum, Enums: []string{"en", "zh-Hans", "zh-Hant"}},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "daily_category_contents", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// DailyCategoryContentsTable holds the schema information for the "daily_category_contents" table.
|
||||
DailyCategoryContentsTable = &schema.Table{
|
||||
Name: "daily_category_contents",
|
||||
Columns: DailyCategoryContentsColumns,
|
||||
PrimaryKey: []*schema.Column{DailyCategoryContentsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "daily_category_contents_daily_categories_contents",
|
||||
Columns: []*schema.Column{DailyCategoryContentsColumns[3]},
|
||||
RefColumns: []*schema.Column{DailyCategoriesColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "dailycategorycontent_language_code_daily_category_contents",
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{DailyCategoryContentsColumns[1], DailyCategoryContentsColumns[3]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// DailyContentsColumns holds the columns for the "daily_contents" table.
|
||||
DailyContentsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "language_code", Type: field.TypeEnum, Enums: []string{"en", "zh-Hans", "zh-Hant"}},
|
||||
{Name: "quote", Type: field.TypeString, Size: 2147483647},
|
||||
{Name: "daily_contents", Type: field.TypeString, Nullable: true, Size: 6},
|
||||
}
|
||||
// DailyContentsTable holds the schema information for the "daily_contents" table.
|
||||
DailyContentsTable = &schema.Table{
|
||||
Name: "daily_contents",
|
||||
Columns: DailyContentsColumns,
|
||||
PrimaryKey: []*schema.Column{DailyContentsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "daily_contents_dailies_contents",
|
||||
Columns: []*schema.Column{DailyContentsColumns[3]},
|
||||
RefColumns: []*schema.Column{DailiesColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "dailycontent_language_code_daily_contents",
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{DailyContentsColumns[1], DailyContentsColumns[3]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// MediaColumns holds the columns for the "media" table.
|
||||
MediaColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "storage_id", Type: field.TypeString, Unique: true},
|
||||
{Name: "original_name", Type: field.TypeString},
|
||||
{Name: "mime_type", Type: field.TypeString},
|
||||
{Name: "size", Type: field.TypeInt64},
|
||||
{Name: "url", Type: field.TypeString},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "created_by", Type: field.TypeString, Nullable: true},
|
||||
{Name: "user_media", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// MediaTable holds the schema information for the "media" table.
|
||||
MediaTable = &schema.Table{
|
||||
Name: "media",
|
||||
Columns: MediaColumns,
|
||||
PrimaryKey: []*schema.Column{MediaColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "media_users_media",
|
||||
Columns: []*schema.Column{MediaColumns[9]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
}
|
||||
// PermissionsColumns holds the columns for the "permissions" table.
|
||||
PermissionsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "resource", Type: field.TypeString},
|
||||
{Name: "action", Type: field.TypeString},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
}
|
||||
// PermissionsTable holds the schema information for the "permissions" table.
|
||||
PermissionsTable = &schema.Table{
|
||||
Name: "permissions",
|
||||
Columns: PermissionsColumns,
|
||||
PrimaryKey: []*schema.Column{PermissionsColumns[0]},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "permission_resource_action",
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{PermissionsColumns[1], PermissionsColumns[2]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// PostsColumns holds the columns for the "posts" table.
|
||||
PostsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "status", Type: field.TypeEnum, Enums: []string{"draft", "published", "archived"}, Default: "draft"},
|
||||
{Name: "slug", Type: field.TypeString, Unique: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "category_posts", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// PostsTable holds the schema information for the "posts" table.
|
||||
PostsTable = &schema.Table{
|
||||
Name: "posts",
|
||||
Columns: PostsColumns,
|
||||
PrimaryKey: []*schema.Column{PostsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "posts_categories_posts",
|
||||
Columns: []*schema.Column{PostsColumns[5]},
|
||||
RefColumns: []*schema.Column{CategoriesColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
}
|
||||
// PostContentsColumns holds the columns for the "post_contents" table.
|
||||
PostContentsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "language_code", Type: field.TypeEnum, Enums: []string{"en", "zh-Hans", "zh-Hant"}},
|
||||
{Name: "title", Type: field.TypeString},
|
||||
{Name: "content_markdown", Type: field.TypeString, Size: 2147483647},
|
||||
{Name: "summary", Type: field.TypeString},
|
||||
{Name: "meta_keywords", Type: field.TypeString, Nullable: true},
|
||||
{Name: "meta_description", Type: field.TypeString, Nullable: true},
|
||||
{Name: "slug", Type: field.TypeString},
|
||||
{Name: "post_contents", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// PostContentsTable holds the schema information for the "post_contents" table.
|
||||
PostContentsTable = &schema.Table{
|
||||
Name: "post_contents",
|
||||
Columns: PostContentsColumns,
|
||||
PrimaryKey: []*schema.Column{PostContentsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "post_contents_posts_contents",
|
||||
Columns: []*schema.Column{PostContentsColumns[8]},
|
||||
RefColumns: []*schema.Column{PostsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "postcontent_language_code_post_contents",
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{PostContentsColumns[1], PostContentsColumns[8]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// PostContributorsColumns holds the columns for the "post_contributors" table.
|
||||
PostContributorsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "language_code", Type: field.TypeEnum, Nullable: true, Enums: []string{"en", "zh-Hans", "zh-Hant"}},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "contributor_posts", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "contributor_role_post_contributors", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "post_contributors", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// PostContributorsTable holds the schema information for the "post_contributors" table.
|
||||
PostContributorsTable = &schema.Table{
|
||||
Name: "post_contributors",
|
||||
Columns: PostContributorsColumns,
|
||||
PrimaryKey: []*schema.Column{PostContributorsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "post_contributors_contributors_posts",
|
||||
Columns: []*schema.Column{PostContributorsColumns[3]},
|
||||
RefColumns: []*schema.Column{ContributorsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
{
|
||||
Symbol: "post_contributors_contributor_roles_post_contributors",
|
||||
Columns: []*schema.Column{PostContributorsColumns[4]},
|
||||
RefColumns: []*schema.Column{ContributorRolesColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
{
|
||||
Symbol: "post_contributors_posts_contributors",
|
||||
Columns: []*schema.Column{PostContributorsColumns[5]},
|
||||
RefColumns: []*schema.Column{PostsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "postcontributor_language_code_post_contributors_contributor_posts_contributor_role_post_contributors",
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{PostContributorsColumns[1], PostContributorsColumns[5], PostContributorsColumns[3], PostContributorsColumns[4]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// RolesColumns holds the columns for the "roles" table.
|
||||
RolesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString, Unique: true},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
}
|
||||
// RolesTable holds the schema information for the "roles" table.
|
||||
RolesTable = &schema.Table{
|
||||
Name: "roles",
|
||||
Columns: RolesColumns,
|
||||
PrimaryKey: []*schema.Column{RolesColumns[0]},
|
||||
}
|
||||
// UsersColumns holds the columns for the "users" table.
|
||||
UsersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "email", Type: field.TypeString, Unique: true},
|
||||
{Name: "password_hash", Type: field.TypeString},
|
||||
{Name: "status", Type: field.TypeEnum, Enums: []string{"active", "inactive", "banned"}, Default: "active"},
|
||||
{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]},
|
||||
}
|
||||
// RolePermissionsColumns holds the columns for the "role_permissions" table.
|
||||
RolePermissionsColumns = []*schema.Column{
|
||||
{Name: "role_id", Type: field.TypeInt},
|
||||
{Name: "permission_id", Type: field.TypeInt},
|
||||
}
|
||||
// RolePermissionsTable holds the schema information for the "role_permissions" table.
|
||||
RolePermissionsTable = &schema.Table{
|
||||
Name: "role_permissions",
|
||||
Columns: RolePermissionsColumns,
|
||||
PrimaryKey: []*schema.Column{RolePermissionsColumns[0], RolePermissionsColumns[1]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "role_permissions_role_id",
|
||||
Columns: []*schema.Column{RolePermissionsColumns[0]},
|
||||
RefColumns: []*schema.Column{RolesColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "role_permissions_permission_id",
|
||||
Columns: []*schema.Column{RolePermissionsColumns[1]},
|
||||
RefColumns: []*schema.Column{PermissionsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// UserRolesColumns holds the columns for the "user_roles" table.
|
||||
UserRolesColumns = []*schema.Column{
|
||||
{Name: "user_id", Type: field.TypeInt},
|
||||
{Name: "role_id", Type: field.TypeInt},
|
||||
}
|
||||
// UserRolesTable holds the schema information for the "user_roles" table.
|
||||
UserRolesTable = &schema.Table{
|
||||
Name: "user_roles",
|
||||
Columns: UserRolesColumns,
|
||||
PrimaryKey: []*schema.Column{UserRolesColumns[0], UserRolesColumns[1]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "user_roles_user_id",
|
||||
Columns: []*schema.Column{UserRolesColumns[0]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "user_roles_role_id",
|
||||
Columns: []*schema.Column{UserRolesColumns[1]},
|
||||
RefColumns: []*schema.Column{RolesColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// Tables holds all the tables in the schema.
|
||||
Tables = []*schema.Table{
|
||||
CategoriesTable,
|
||||
CategoryContentsTable,
|
||||
ContributorsTable,
|
||||
ContributorRolesTable,
|
||||
ContributorSocialLinksTable,
|
||||
DailiesTable,
|
||||
DailyCategoriesTable,
|
||||
DailyCategoryContentsTable,
|
||||
DailyContentsTable,
|
||||
MediaTable,
|
||||
PermissionsTable,
|
||||
PostsTable,
|
||||
PostContentsTable,
|
||||
PostContributorsTable,
|
||||
RolesTable,
|
||||
UsersTable,
|
||||
RolePermissionsTable,
|
||||
UserRolesTable,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
CategoryContentsTable.ForeignKeys[0].RefTable = CategoriesTable
|
||||
ContributorsTable.ForeignKeys[0].RefTable = UsersTable
|
||||
ContributorSocialLinksTable.ForeignKeys[0].RefTable = ContributorsTable
|
||||
DailiesTable.ForeignKeys[0].RefTable = CategoriesTable
|
||||
DailiesTable.ForeignKeys[1].RefTable = DailyCategoriesTable
|
||||
DailyCategoryContentsTable.ForeignKeys[0].RefTable = DailyCategoriesTable
|
||||
DailyContentsTable.ForeignKeys[0].RefTable = DailiesTable
|
||||
MediaTable.ForeignKeys[0].RefTable = UsersTable
|
||||
PostsTable.ForeignKeys[0].RefTable = CategoriesTable
|
||||
PostContentsTable.ForeignKeys[0].RefTable = PostsTable
|
||||
PostContributorsTable.ForeignKeys[0].RefTable = ContributorsTable
|
||||
PostContributorsTable.ForeignKeys[1].RefTable = ContributorRolesTable
|
||||
PostContributorsTable.ForeignKeys[2].RefTable = PostsTable
|
||||
RolePermissionsTable.ForeignKeys[0].RefTable = RolesTable
|
||||
RolePermissionsTable.ForeignKeys[1].RefTable = PermissionsTable
|
||||
UserRolesTable.ForeignKeys[0].RefTable = UsersTable
|
||||
UserRolesTable.ForeignKeys[1].RefTable = RolesTable
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue