Help us shape the future of Go! Take the 2026 Go Developer Survey

migrate

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 7 Imported by: 0

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 (
	// ConnectforgeBindingsColumns holds the columns for the "connectforge_bindings" table.
	ConnectforgeBindingsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "owner_id", Type: field.TypeString},
		{Name: "connection_id", Type: field.TypeString},
		{Name: "consumer_kind", Type: field.TypeString},
		{Name: "consumer_id", Type: field.TypeString},
		{Name: "purpose", Type: field.TypeString},
		{Name: "created_at", Type: field.TypeTime},
	}
	// ConnectforgeBindingsTable holds the schema information for the "connectforge_bindings" table.
	ConnectforgeBindingsTable = &schema.Table{
		Name:       "connectforge_bindings",
		Columns:    ConnectforgeBindingsColumns,
		PrimaryKey: []*schema.Column{ConnectforgeBindingsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "binding_owner_id_connection_id_consumer_kind_consumer_id_purpose",
				Unique:  true,
				Columns: []*schema.Column{ConnectforgeBindingsColumns[1], ConnectforgeBindingsColumns[2], ConnectforgeBindingsColumns[3], ConnectforgeBindingsColumns[4], ConnectforgeBindingsColumns[5]},
			},
		},
	}
	// ConnectforgeConnectionsColumns holds the columns for the "connectforge_connections" table.
	ConnectforgeConnectionsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "owner_id", Type: field.TypeString},
		{Name: "connection_id", Type: field.TypeString},
		{Name: "provider", Type: field.TypeString},
		{Name: "auth_method", Type: field.TypeString},
		{Name: "display_name", Type: field.TypeString},
		{Name: "external_account_id", Type: field.TypeString, Default: ""},
		{Name: "external_label", Type: field.TypeString, Default: ""},
		{Name: "scopes", Type: field.TypeJSON, Nullable: true},
		{Name: "state", Type: field.TypeString},
		{Name: "health", Type: field.TypeJSON},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "created_by_kind", Type: field.TypeString},
		{Name: "created_by_id", Type: field.TypeString},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "revision", Type: field.TypeUint64},
	}
	// ConnectforgeConnectionsTable holds the schema information for the "connectforge_connections" table.
	ConnectforgeConnectionsTable = &schema.Table{
		Name:       "connectforge_connections",
		Columns:    ConnectforgeConnectionsColumns,
		PrimaryKey: []*schema.Column{ConnectforgeConnectionsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "connection_owner_id_connection_id",
				Unique:  true,
				Columns: []*schema.Column{ConnectforgeConnectionsColumns[1], ConnectforgeConnectionsColumns[2]},
			},
			{
				Name:    "connection_owner_id_provider",
				Unique:  false,
				Columns: []*schema.Column{ConnectforgeConnectionsColumns[1], ConnectforgeConnectionsColumns[3]},
			},
		},
	}
	// ConnectforgeCredentialsColumns holds the columns for the "connectforge_credentials" table.
	ConnectforgeCredentialsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "owner_id", Type: field.TypeString},
		{Name: "connection_id", Type: field.TypeString},
		{Name: "version", Type: field.TypeInt},
		{Name: "kind", Type: field.TypeString},
		{Name: "ciphertext", Type: field.TypeBytes},
		{Name: "expires_at", Type: field.TypeTime, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
	}
	// ConnectforgeCredentialsTable holds the schema information for the "connectforge_credentials" table.
	ConnectforgeCredentialsTable = &schema.Table{
		Name:       "connectforge_credentials",
		Columns:    ConnectforgeCredentialsColumns,
		PrimaryKey: []*schema.Column{ConnectforgeCredentialsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "credential_owner_id_connection_id_version",
				Unique:  true,
				Columns: []*schema.Column{ConnectforgeCredentialsColumns[1], ConnectforgeCredentialsColumns[2], ConnectforgeCredentialsColumns[3]},
			},
		},
	}
	// ConnectforgeGrantsColumns holds the columns for the "connectforge_grants" table.
	ConnectforgeGrantsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "owner_id", Type: field.TypeString},
		{Name: "connection_id", Type: field.TypeString},
		{Name: "principal_kind", Type: field.TypeString},
		{Name: "principal_id", Type: field.TypeString},
		{Name: "actions", Type: field.TypeJSON},
	}
	// ConnectforgeGrantsTable holds the schema information for the "connectforge_grants" table.
	ConnectforgeGrantsTable = &schema.Table{
		Name:       "connectforge_grants",
		Columns:    ConnectforgeGrantsColumns,
		PrimaryKey: []*schema.Column{ConnectforgeGrantsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "grant_owner_id_connection_id_principal_kind_principal_id",
				Unique:  true,
				Columns: []*schema.Column{ConnectforgeGrantsColumns[1], ConnectforgeGrantsColumns[2], ConnectforgeGrantsColumns[3], ConnectforgeGrantsColumns[4]},
			},
		},
	}
	// ConnectforgeLeasesColumns holds the columns for the "connectforge_leases" table.
	ConnectforgeLeasesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString, Unique: true},
		{Name: "token", Type: field.TypeString},
		{Name: "expires_at", Type: field.TypeTime},
	}
	// ConnectforgeLeasesTable holds the schema information for the "connectforge_leases" table.
	ConnectforgeLeasesTable = &schema.Table{
		Name:       "connectforge_leases",
		Columns:    ConnectforgeLeasesColumns,
		PrimaryKey: []*schema.Column{ConnectforgeLeasesColumns[0]},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		ConnectforgeBindingsTable,
		ConnectforgeConnectionsTable,
		ConnectforgeCredentialsTable,
		ConnectforgeGrantsTable,
		ConnectforgeLeasesTable,
	}
)

Functions

func Create

func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error

Create creates all table resources using the given schema driver.

Types

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema is the API for creating, migrating and dropping a schema.

func NewSchema

func NewSchema(drv dialect.Driver) *Schema

NewSchema creates a new schema client.

func (*Schema) Create

func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error

Create creates all schema resources.

func (*Schema) WriteTo

func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error

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)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL