update migrate
This commit is contained in:
12
ent/migrate/migrations/20230405104340_migration_name.sql
Normal file
12
ent/migrate/migrations/20230405104340_migration_name.sql
Normal file
@ -0,0 +1,12 @@
|
||||
-- Create "cards" table
|
||||
CREATE TABLE `cards` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `password` text NOT NULL, `card` integer NULL, `status` text NULL, `cp` integer NULL, `url` text NULL DEFAULT 'https://card.syui.ai', `created_at` datetime NULL, `user_card` integer NOT NULL, CONSTRAINT `cards_users_card` FOREIGN KEY (`user_card`) REFERENCES `users` (`id`) ON DELETE NO ACTION);
|
||||
-- Create "groups" table
|
||||
CREATE TABLE `groups` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` text NOT NULL, `password` text NOT NULL);
|
||||
-- Create index "group_name" to table: "groups"
|
||||
CREATE UNIQUE INDEX `group_name` ON `groups` (`name`);
|
||||
-- Create "users" table
|
||||
CREATE TABLE `users` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `username` text NOT NULL, `password` text NOT NULL, `created_at` datetime NULL, `updated_at` datetime NULL, `next` text NULL DEFAULT '20230405', `group_users` integer NULL, CONSTRAINT `users_groups_users` FOREIGN KEY (`group_users`) REFERENCES `groups` (`id`) ON DELETE SET NULL);
|
||||
-- Create index "users_username_key" to table: "users"
|
||||
CREATE UNIQUE INDEX `users_username_key` ON `users` (`username`);
|
||||
-- Create index "user_username" to table: "users"
|
||||
CREATE UNIQUE INDEX `user_username` ON `users` (`username`);
|
2
ent/migrate/migrations/atlas.sum
Normal file
2
ent/migrate/migrations/atlas.sum
Normal file
@ -0,0 +1,2 @@
|
||||
h1:GU79ffcSbQHeq4BLGuuAdObBOt0WLTcsQx+AucxEqkA=
|
||||
20230405104340_migration_name.sql h1:vlsZT8ob1qpLmBAGPqNBBG/iFact7wy1pb27tAavvRU=
|
@ -11,6 +11,7 @@ var (
|
||||
// CardsColumns holds the columns for the "cards" table.
|
||||
CardsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
{Name: "card", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "status", Type: field.TypeString, Nullable: true},
|
||||
{Name: "cp", Type: field.TypeInt, Nullable: true},
|
||||
@ -26,7 +27,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "cards_users_card",
|
||||
Columns: []*schema.Column{CardsColumns[6]},
|
||||
Columns: []*schema.Column{CardsColumns[7]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
@ -36,6 +37,7 @@ var (
|
||||
GroupsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
}
|
||||
// GroupsTable holds the schema information for the "groups" table.
|
||||
GroupsTable = &schema.Table{
|
||||
@ -54,9 +56,10 @@ var (
|
||||
UsersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "username", Type: field.TypeString, Unique: true, Size: 30},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
{Name: "created_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230404"},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230406"},
|
||||
{Name: "group_users", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// UsersTable holds the schema information for the "users" table.
|
||||
@ -67,7 +70,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "users_groups_users",
|
||||
Columns: []*schema.Column{UsersColumns[5]},
|
||||
Columns: []*schema.Column{UsersColumns[6]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
|
Reference in New Issue
Block a user