migrate

package
v0.0.0-...-19e0465 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: Apache-2.0 Imports: 6 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
	// 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
)
View Source
var (
	// FlowDefinitionsColumns holds the columns for the "flow_definitions" table.
	FlowDefinitionsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeString, Unique: true},
		{Name: "created_at", Type: field.TypeInt64},
		{Name: "updated_at", Type: field.TypeInt64},
		{Name: "deleted_at", Type: field.TypeInt64, Nullable: true, Default: 0},
		{Name: "name", Type: field.TypeString},
		{Name: "status", Type: field.TypeInt8, Default: 0},
		{Name: "model", Type: field.TypeJSON},
		{Name: "remark", Type: field.TypeString, Nullable: true, Default: ""},
	}
	// FlowDefinitionsTable holds the schema information for the "flow_definitions" table.
	FlowDefinitionsTable = &schema.Table{
		Name:       "flow_definitions",
		Columns:    FlowDefinitionsColumns,
		PrimaryKey: []*schema.Column{FlowDefinitionsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "flowdefinition_created_at",
				Unique:  false,
				Columns: []*schema.Column{FlowDefinitionsColumns[1]},
			},
			{
				Name:    "flowdefinition_deleted_at",
				Unique:  false,
				Columns: []*schema.Column{FlowDefinitionsColumns[3]},
			},
		},
	}
	// FlowDeploymentsColumns holds the columns for the "flow_deployments" table.
	FlowDeploymentsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeString, Unique: true},
		{Name: "created_at", Type: field.TypeInt64},
		{Name: "updated_at", Type: field.TypeInt64},
		{Name: "deleted_at", Type: field.TypeInt64, Nullable: true, Default: 0},
		{Name: "name", Type: field.TypeString},
		{Name: "status", Type: field.TypeInt8, Default: 0},
		{Name: "model", Type: field.TypeJSON},
		{Name: "remark", Type: field.TypeString, Nullable: true, Default: ""},
		{Name: "flow_definition_id", Type: field.TypeString},
	}
	// FlowDeploymentsTable holds the schema information for the "flow_deployments" table.
	FlowDeploymentsTable = &schema.Table{
		Name:       "flow_deployments",
		Columns:    FlowDeploymentsColumns,
		PrimaryKey: []*schema.Column{FlowDeploymentsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "flow_deployments_flow_definitions_flow_deployments",
				Columns:    []*schema.Column{FlowDeploymentsColumns[8]},
				RefColumns: []*schema.Column{FlowDefinitionsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "flowdeployment_created_at",
				Unique:  false,
				Columns: []*schema.Column{FlowDeploymentsColumns[1]},
			},
			{
				Name:    "flowdeployment_deleted_at",
				Unique:  false,
				Columns: []*schema.Column{FlowDeploymentsColumns[3]},
			},
			{
				Name:    "flowdeployment_flow_definition_id",
				Unique:  false,
				Columns: []*schema.Column{FlowDeploymentsColumns[8]},
			},
		},
	}
	// FlowInstancesColumns holds the columns for the "flow_instances" table.
	FlowInstancesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeString, Unique: true},
		{Name: "created_at", Type: field.TypeInt64},
		{Name: "updated_at", Type: field.TypeInt64},
		{Name: "deleted_at", Type: field.TypeInt64, Nullable: true, Default: 0},
		{Name: "ref_id", Type: field.TypeString},
		{Name: "status", Type: field.TypeInt8, Default: 0},
		{Name: "flow_deployment_id", Type: field.TypeString},
	}
	// FlowInstancesTable holds the schema information for the "flow_instances" table.
	FlowInstancesTable = &schema.Table{
		Name:       "flow_instances",
		Columns:    FlowInstancesColumns,
		PrimaryKey: []*schema.Column{FlowInstancesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "flow_instances_flow_deployments_flow_instances",
				Columns:    []*schema.Column{FlowInstancesColumns[6]},
				RefColumns: []*schema.Column{FlowDeploymentsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "flowinstance_created_at",
				Unique:  false,
				Columns: []*schema.Column{FlowInstancesColumns[1]},
			},
			{
				Name:    "flowinstance_deleted_at",
				Unique:  false,
				Columns: []*schema.Column{FlowInstancesColumns[3]},
			},
			{
				Name:    "flowinstance_flow_deployment_id",
				Unique:  false,
				Columns: []*schema.Column{FlowInstancesColumns[6]},
			},
			{
				Name:    "flowinstance_ref_id",
				Unique:  false,
				Columns: []*schema.Column{FlowInstancesColumns[4]},
			},
			{
				Name:    "flowinstance_status",
				Unique:  false,
				Columns: []*schema.Column{FlowInstancesColumns[5]},
			},
		},
	}
	// FlowInstanceDataColumns holds the columns for the "flow_instance_data" table.
	FlowInstanceDataColumns = []*schema.Column{
		{Name: "id", Type: field.TypeString, Unique: true},
		{Name: "created_at", Type: field.TypeInt64},
		{Name: "updated_at", Type: field.TypeInt64},
		{Name: "deleted_at", Type: field.TypeInt64, Nullable: true, Default: 0},
		{Name: "flow_instance_id", Type: field.TypeString},
		{Name: "flow_node_instance_id", Type: field.TypeString, Nullable: true},
		{Name: "node_key", Type: field.TypeString, Nullable: true},
		{Name: "data", Type: field.TypeJSON, Nullable: true},
		{Name: "type", Type: field.TypeInt8, Default: 0},
	}
	// FlowInstanceDataTable holds the schema information for the "flow_instance_data" table.
	FlowInstanceDataTable = &schema.Table{
		Name:       "flow_instance_data",
		Columns:    FlowInstanceDataColumns,
		PrimaryKey: []*schema.Column{FlowInstanceDataColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "flowinstancedata_created_at",
				Unique:  false,
				Columns: []*schema.Column{FlowInstanceDataColumns[1]},
			},
			{
				Name:    "flowinstancedata_deleted_at",
				Unique:  false,
				Columns: []*schema.Column{FlowInstanceDataColumns[3]},
			},
		},
	}
	// FlowNodeInstancesColumns holds the columns for the "flow_node_instances" table.
	FlowNodeInstancesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeString, Unique: true},
		{Name: "created_at", Type: field.TypeInt64},
		{Name: "updated_at", Type: field.TypeInt64},
		{Name: "deleted_at", Type: field.TypeInt64, Nullable: true, Default: 0},
		{Name: "source_flow_node_instance_id", Type: field.TypeString, Nullable: true, Default: ""},
		{Name: "flow_instance_data_id", Type: field.TypeString, Nullable: true, Default: ""},
		{Name: "node_key", Type: field.TypeString},
		{Name: "source_node_key", Type: field.TypeString, Nullable: true, Default: ""},
		{Name: "status", Type: field.TypeInt8, Default: 0},
		{Name: "flow_instance_id", Type: field.TypeString},
	}
	// FlowNodeInstancesTable holds the schema information for the "flow_node_instances" table.
	FlowNodeInstancesTable = &schema.Table{
		Name:       "flow_node_instances",
		Columns:    FlowNodeInstancesColumns,
		PrimaryKey: []*schema.Column{FlowNodeInstancesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "flow_node_instances_flow_instances_flow_node_instances",
				Columns:    []*schema.Column{FlowNodeInstancesColumns[9]},
				RefColumns: []*schema.Column{FlowInstancesColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "flownodeinstance_created_at",
				Unique:  false,
				Columns: []*schema.Column{FlowNodeInstancesColumns[1]},
			},
			{
				Name:    "flownodeinstance_deleted_at",
				Unique:  false,
				Columns: []*schema.Column{FlowNodeInstancesColumns[3]},
			},
			{
				Name:    "flownodeinstance_flow_instance_id",
				Unique:  false,
				Columns: []*schema.Column{FlowNodeInstancesColumns[9]},
			},
			{
				Name:    "flownodeinstance_status",
				Unique:  false,
				Columns: []*schema.Column{FlowNodeInstancesColumns[8]},
			},
		},
	}
	// FlowNodeInstanceLogsColumns holds the columns for the "flow_node_instance_logs" table.
	FlowNodeInstanceLogsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeString, Unique: true},
		{Name: "created_at", Type: field.TypeInt64},
		{Name: "updated_at", Type: field.TypeInt64},
		{Name: "deleted_at", Type: field.TypeInt64, Nullable: true, Default: 0},
		{Name: "flow_instance_id", Type: field.TypeString},
		{Name: "flow_node_instance_id", Type: field.TypeString},
		{Name: "flow_instance_data_id", Type: field.TypeString, Nullable: true, Default: ""},
		{Name: "node_key", Type: field.TypeString},
		{Name: "type", Type: field.TypeInt8, Default: 0},
		{Name: "status", Type: field.TypeInt8, Default: 0},
	}
	// FlowNodeInstanceLogsTable holds the schema information for the "flow_node_instance_logs" table.
	FlowNodeInstanceLogsTable = &schema.Table{
		Name:       "flow_node_instance_logs",
		Columns:    FlowNodeInstanceLogsColumns,
		PrimaryKey: []*schema.Column{FlowNodeInstanceLogsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "flownodeinstancelog_created_at",
				Unique:  false,
				Columns: []*schema.Column{FlowNodeInstanceLogsColumns[1]},
			},
			{
				Name:    "flownodeinstancelog_deleted_at",
				Unique:  false,
				Columns: []*schema.Column{FlowNodeInstanceLogsColumns[3]},
			},
			{
				Name:    "flownodeinstancelog_flow_instance_id",
				Unique:  false,
				Columns: []*schema.Column{FlowNodeInstanceLogsColumns[4]},
			},
			{
				Name:    "flownodeinstancelog_flow_node_instance_id",
				Unique:  false,
				Columns: []*schema.Column{FlowNodeInstanceLogsColumns[5]},
			},
		},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		FlowDefinitionsTable,
		FlowDeploymentsTable,
		FlowInstancesTable,
		FlowInstanceDataTable,
		FlowNodeInstancesTable,
		FlowNodeInstanceLogsTable,
	}
)

Functions

This section is empty.

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