mirror of
https://github.com/versia-pub/versia-go.git
synced 2026-03-13 04:29:15 +01:00
chore: init
This commit is contained in:
commit
320715f3e7
174 changed files with 42083 additions and 0 deletions
64
ent/migrate/migrate.go
Normal file
64
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...)
|
||||
}
|
||||
265
ent/migrate/schema.go
Normal file
265
ent/migrate/schema.go
Normal file
|
|
@ -0,0 +1,265 @@
|
|||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
var (
|
||||
// AttachmentsColumns holds the columns for the "attachments" table.
|
||||
AttachmentsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "is_remote", Type: field.TypeBool},
|
||||
{Name: "uri", Type: field.TypeString},
|
||||
{Name: "extensions", Type: field.TypeJSON},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "description", Type: field.TypeString, Size: 384},
|
||||
{Name: "sha256", Type: field.TypeBytes},
|
||||
{Name: "size", Type: field.TypeInt},
|
||||
{Name: "blurhash", Type: field.TypeString, Nullable: true},
|
||||
{Name: "height", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "width", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "fps", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "mime_type", Type: field.TypeString},
|
||||
{Name: "attachment_author", Type: field.TypeUUID},
|
||||
{Name: "note_attachments", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
// AttachmentsTable holds the schema information for the "attachments" table.
|
||||
AttachmentsTable = &schema.Table{
|
||||
Name: "attachments",
|
||||
Columns: AttachmentsColumns,
|
||||
PrimaryKey: []*schema.Column{AttachmentsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "attachments_users_author",
|
||||
Columns: []*schema.Column{AttachmentsColumns[14]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
{
|
||||
Symbol: "attachments_notes_attachments",
|
||||
Columns: []*schema.Column{AttachmentsColumns[15]},
|
||||
RefColumns: []*schema.Column{NotesColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
}
|
||||
// FollowsColumns holds the columns for the "follows" table.
|
||||
FollowsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "is_remote", Type: field.TypeBool},
|
||||
{Name: "uri", Type: field.TypeString},
|
||||
{Name: "extensions", Type: field.TypeJSON},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "accepted"}, Default: "pending"},
|
||||
{Name: "follow_follower", Type: field.TypeUUID},
|
||||
{Name: "follow_followee", Type: field.TypeUUID},
|
||||
}
|
||||
// FollowsTable holds the schema information for the "follows" table.
|
||||
FollowsTable = &schema.Table{
|
||||
Name: "follows",
|
||||
Columns: FollowsColumns,
|
||||
PrimaryKey: []*schema.Column{FollowsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "follows_users_follower",
|
||||
Columns: []*schema.Column{FollowsColumns[7]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
{
|
||||
Symbol: "follows_users_followee",
|
||||
Columns: []*schema.Column{FollowsColumns[8]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "follow_follow_follower_follow_followee",
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{FollowsColumns[7], FollowsColumns[8]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// ImagesColumns holds the columns for the "images" table.
|
||||
ImagesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "url", Type: field.TypeString},
|
||||
{Name: "mime_type", Type: field.TypeString},
|
||||
}
|
||||
// ImagesTable holds the schema information for the "images" table.
|
||||
ImagesTable = &schema.Table{
|
||||
Name: "images",
|
||||
Columns: ImagesColumns,
|
||||
PrimaryKey: []*schema.Column{ImagesColumns[0]},
|
||||
}
|
||||
// NotesColumns holds the columns for the "notes" table.
|
||||
NotesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "is_remote", Type: field.TypeBool},
|
||||
{Name: "uri", Type: field.TypeString},
|
||||
{Name: "extensions", Type: field.TypeJSON},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "subject", Type: field.TypeString, Nullable: true, Size: 384},
|
||||
{Name: "content", Type: field.TypeString},
|
||||
{Name: "is_sensitive", Type: field.TypeBool, Default: false},
|
||||
{Name: "visibility", Type: field.TypeEnum, Enums: []string{"public", "unlisted", "followers", "direct"}, Default: "public"},
|
||||
{Name: "note_author", Type: field.TypeUUID},
|
||||
}
|
||||
// NotesTable holds the schema information for the "notes" table.
|
||||
NotesTable = &schema.Table{
|
||||
Name: "notes",
|
||||
Columns: NotesColumns,
|
||||
PrimaryKey: []*schema.Column{NotesColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "notes_users_author",
|
||||
Columns: []*schema.Column{NotesColumns[10]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
}
|
||||
// ServerMetadataColumns holds the columns for the "server_metadata" table.
|
||||
ServerMetadataColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "is_remote", Type: field.TypeBool},
|
||||
{Name: "uri", Type: field.TypeString},
|
||||
{Name: "extensions", Type: field.TypeJSON},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true},
|
||||
{Name: "version", Type: field.TypeString},
|
||||
{Name: "supported_extensions", Type: field.TypeJSON},
|
||||
{Name: "server_metadata_follower", Type: field.TypeUUID},
|
||||
{Name: "server_metadata_followee", Type: field.TypeUUID},
|
||||
}
|
||||
// ServerMetadataTable holds the schema information for the "server_metadata" table.
|
||||
ServerMetadataTable = &schema.Table{
|
||||
Name: "server_metadata",
|
||||
Columns: ServerMetadataColumns,
|
||||
PrimaryKey: []*schema.Column{ServerMetadataColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "server_metadata_users_follower",
|
||||
Columns: []*schema.Column{ServerMetadataColumns[10]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
{
|
||||
Symbol: "server_metadata_users_followee",
|
||||
Columns: []*schema.Column{ServerMetadataColumns[11]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "servermetadata_server_metadata_follower_server_metadata_followee",
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{ServerMetadataColumns[10], ServerMetadataColumns[11]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// UsersColumns holds the columns for the "users" table.
|
||||
UsersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "is_remote", Type: field.TypeBool},
|
||||
{Name: "uri", Type: field.TypeString},
|
||||
{Name: "extensions", Type: field.TypeJSON},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "username", Type: field.TypeString, Unique: true, Size: 32},
|
||||
{Name: "password_hash", Type: field.TypeBytes, Nullable: true},
|
||||
{Name: "display_name", Type: field.TypeString, Nullable: true, Size: 256},
|
||||
{Name: "biography", Type: field.TypeString, Nullable: true},
|
||||
{Name: "public_key", Type: field.TypeBytes},
|
||||
{Name: "private_key", Type: field.TypeBytes, Nullable: true},
|
||||
{Name: "indexable", Type: field.TypeBool, Default: true},
|
||||
{Name: "privacy_level", Type: field.TypeEnum, Enums: []string{"public", "restricted", "private"}, Default: "public"},
|
||||
{Name: "fields", Type: field.TypeJSON},
|
||||
{Name: "inbox", Type: field.TypeString},
|
||||
{Name: "featured", Type: field.TypeString},
|
||||
{Name: "followers", Type: field.TypeString},
|
||||
{Name: "following", Type: field.TypeString},
|
||||
{Name: "outbox", Type: field.TypeString},
|
||||
{Name: "user_avatar_image", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "user_header_image", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// UsersTable holds the schema information for the "users" table.
|
||||
UsersTable = &schema.Table{
|
||||
Name: "users",
|
||||
Columns: UsersColumns,
|
||||
PrimaryKey: []*schema.Column{UsersColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "users_images_avatarImage",
|
||||
Columns: []*schema.Column{UsersColumns[20]},
|
||||
RefColumns: []*schema.Column{ImagesColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
{
|
||||
Symbol: "users_images_headerImage",
|
||||
Columns: []*schema.Column{UsersColumns[21]},
|
||||
RefColumns: []*schema.Column{ImagesColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
}
|
||||
// NoteMentionsColumns holds the columns for the "note_mentions" table.
|
||||
NoteMentionsColumns = []*schema.Column{
|
||||
{Name: "note_id", Type: field.TypeUUID},
|
||||
{Name: "user_id", Type: field.TypeUUID},
|
||||
}
|
||||
// NoteMentionsTable holds the schema information for the "note_mentions" table.
|
||||
NoteMentionsTable = &schema.Table{
|
||||
Name: "note_mentions",
|
||||
Columns: NoteMentionsColumns,
|
||||
PrimaryKey: []*schema.Column{NoteMentionsColumns[0], NoteMentionsColumns[1]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "note_mentions_note_id",
|
||||
Columns: []*schema.Column{NoteMentionsColumns[0]},
|
||||
RefColumns: []*schema.Column{NotesColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "note_mentions_user_id",
|
||||
Columns: []*schema.Column{NoteMentionsColumns[1]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// Tables holds all the tables in the schema.
|
||||
Tables = []*schema.Table{
|
||||
AttachmentsTable,
|
||||
FollowsTable,
|
||||
ImagesTable,
|
||||
NotesTable,
|
||||
ServerMetadataTable,
|
||||
UsersTable,
|
||||
NoteMentionsTable,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
AttachmentsTable.ForeignKeys[0].RefTable = UsersTable
|
||||
AttachmentsTable.ForeignKeys[1].RefTable = NotesTable
|
||||
FollowsTable.ForeignKeys[0].RefTable = UsersTable
|
||||
FollowsTable.ForeignKeys[1].RefTable = UsersTable
|
||||
NotesTable.ForeignKeys[0].RefTable = UsersTable
|
||||
ServerMetadataTable.ForeignKeys[0].RefTable = UsersTable
|
||||
ServerMetadataTable.ForeignKeys[1].RefTable = UsersTable
|
||||
UsersTable.ForeignKeys[0].RefTable = ImagesTable
|
||||
UsersTable.ForeignKeys[1].RefTable = ImagesTable
|
||||
NoteMentionsTable.ForeignKeys[0].RefTable = NotesTable
|
||||
NoteMentionsTable.ForeignKeys[1].RefTable = UsersTable
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue