migrate

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 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 (
	// ConnectionforgeBindingsColumns holds the columns for the "connectionforge_bindings" table.
	ConnectionforgeBindingsColumns = []*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},
	}
	// ConnectionforgeBindingsTable holds the schema information for the "connectionforge_bindings" table.
	ConnectionforgeBindingsTable = &schema.Table{
		Name:       "connectionforge_bindings",
		Columns:    ConnectionforgeBindingsColumns,
		PrimaryKey: []*schema.Column{ConnectionforgeBindingsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "binding_owner_id_connection_id_consumer_kind_consumer_id_purpose",
				Unique:  true,
				Columns: []*schema.Column{ConnectionforgeBindingsColumns[1], ConnectionforgeBindingsColumns[2], ConnectionforgeBindingsColumns[3], ConnectionforgeBindingsColumns[4], ConnectionforgeBindingsColumns[5]},
			},
		},
	}
	// ConnectionforgeConnectionsColumns holds the columns for the "connectionforge_connections" table.
	ConnectionforgeConnectionsColumns = []*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},
	}
	// ConnectionforgeConnectionsTable holds the schema information for the "connectionforge_connections" table.
	ConnectionforgeConnectionsTable = &schema.Table{
		Name:       "connectionforge_connections",
		Columns:    ConnectionforgeConnectionsColumns,
		PrimaryKey: []*schema.Column{ConnectionforgeConnectionsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "connection_owner_id_connection_id",
				Unique:  true,
				Columns: []*schema.Column{ConnectionforgeConnectionsColumns[1], ConnectionforgeConnectionsColumns[2]},
			},
			{
				Name:    "connection_owner_id_provider",
				Unique:  false,
				Columns: []*schema.Column{ConnectionforgeConnectionsColumns[1], ConnectionforgeConnectionsColumns[3]},
			},
		},
	}
	// ConnectionforgeCredentialsColumns holds the columns for the "connectionforge_credentials" table.
	ConnectionforgeCredentialsColumns = []*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},
	}
	// ConnectionforgeCredentialsTable holds the schema information for the "connectionforge_credentials" table.
	ConnectionforgeCredentialsTable = &schema.Table{
		Name:       "connectionforge_credentials",
		Columns:    ConnectionforgeCredentialsColumns,
		PrimaryKey: []*schema.Column{ConnectionforgeCredentialsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "credential_owner_id_connection_id_version",
				Unique:  true,
				Columns: []*schema.Column{ConnectionforgeCredentialsColumns[1], ConnectionforgeCredentialsColumns[2], ConnectionforgeCredentialsColumns[3]},
			},
		},
	}
	// ConnectionforgeGrantsColumns holds the columns for the "connectionforge_grants" table.
	ConnectionforgeGrantsColumns = []*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},
	}
	// ConnectionforgeGrantsTable holds the schema information for the "connectionforge_grants" table.
	ConnectionforgeGrantsTable = &schema.Table{
		Name:       "connectionforge_grants",
		Columns:    ConnectionforgeGrantsColumns,
		PrimaryKey: []*schema.Column{ConnectionforgeGrantsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "grant_owner_id_connection_id_principal_kind_principal_id",
				Unique:  true,
				Columns: []*schema.Column{ConnectionforgeGrantsColumns[1], ConnectionforgeGrantsColumns[2], ConnectionforgeGrantsColumns[3], ConnectionforgeGrantsColumns[4]},
			},
		},
	}
	// ConnectionforgeLeasesColumns holds the columns for the "connectionforge_leases" table.
	ConnectionforgeLeasesColumns = []*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},
	}
	// ConnectionforgeLeasesTable holds the schema information for the "connectionforge_leases" table.
	ConnectionforgeLeasesTable = &schema.Table{
		Name:       "connectionforge_leases",
		Columns:    ConnectionforgeLeasesColumns,
		PrimaryKey: []*schema.Column{ConnectionforgeLeasesColumns[0]},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		ConnectionforgeBindingsTable,
		ConnectionforgeConnectionsTable,
		ConnectionforgeCredentialsTable,
		ConnectionforgeGrantsTable,
		ConnectionforgeLeasesTable,
	}
)

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