init: create project

This commit is contained in:
kallydev
2020-11-28 18:32:36 +08:00
commit a970ad7653
83 changed files with 24196 additions and 0 deletions

View File

@ -0,0 +1,72 @@
// Code generated by entc, DO NOT EDIT.
package migrate
import (
"context"
"fmt"
"io"
"github.com/facebook/ent/dialect"
"github.com/facebook/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
// WithFixture sets the foreign-key renaming option to the migration when upgrading
// ent from v0.1.0 (issue-#285). Defaults to false.
WithFixture = schema.WithFixture
// 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
universalID bool
}
// 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 {
migrate, err := schema.NewMigrate(s.drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %v", 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 {
drv := &schema.WriteDriver{
Writer: w,
Driver: s.drv,
}
migrate, err := schema.NewMigrate(drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %v", err)
}
return migrate.Create(ctx, Tables...)
}

View File

@ -0,0 +1,64 @@
// Code generated by entc, DO NOT EDIT.
package migrate
import (
"github.com/facebook/ent/dialect/sql/schema"
"github.com/facebook/ent/schema/field"
)
var (
// JdColumns holds the columns for the "jd" table.
JdColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "name", Type: field.TypeString},
{Name: "nickname", Type: field.TypeString},
{Name: "password", Type: field.TypeString},
{Name: "email", Type: field.TypeString},
{Name: "id_number", Type: field.TypeString},
{Name: "phone_number", Type: field.TypeInt64},
}
// JdTable holds the schema information for the "jd" table.
JdTable = &schema.Table{
Name: "jd",
Columns: JdColumns,
PrimaryKey: []*schema.Column{JdColumns[0]},
ForeignKeys: []*schema.ForeignKey{},
}
// QqColumns holds the columns for the "qq" table.
QqColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "qq_number", Type: field.TypeInt64},
{Name: "phone_number", Type: field.TypeInt64},
}
// QqTable holds the schema information for the "qq" table.
QqTable = &schema.Table{
Name: "qq",
Columns: QqColumns,
PrimaryKey: []*schema.Column{QqColumns[0]},
ForeignKeys: []*schema.ForeignKey{},
}
// SfColumns holds the columns for the "sf" table.
SfColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "name", Type: field.TypeString},
{Name: "phone_number", Type: field.TypeInt64},
{Name: "address", Type: field.TypeString},
}
// SfTable holds the schema information for the "sf" table.
SfTable = &schema.Table{
Name: "sf",
Columns: SfColumns,
PrimaryKey: []*schema.Column{SfColumns[0]},
ForeignKeys: []*schema.ForeignKey{},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
JdTable,
QqTable,
SfTable,
}
)
func init() {
}