migrate

package
v0.0.0-...-c43fb32 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 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 (
	// ClientCompaniesColumns holds the columns for the "client_companies" table.
	ClientCompaniesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUint64, Increment: true},
		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
		{Name: "sort", Type: field.TypeUint32, Comment: "Sort Number | 排序编号", Default: 1},
		{Name: "code", Type: field.TypeInt32, Comment: "Code | 公司编码"},
		{Name: "nickname", Type: field.TypeString, Comment: "Nickname | 公司简称"},
		{Name: "address", Type: field.TypeString, Nullable: true, Comment: "Address | 公司地址"},
		{Name: "remark", Type: field.TypeString, Nullable: true, Comment: "Remark | 备注"},
	}
	// ClientCompaniesTable holds the schema information for the "client_companies" table.
	ClientCompaniesTable = &schema.Table{
		Name:       "client_companies",
		Columns:    ClientCompaniesColumns,
		PrimaryKey: []*schema.Column{ClientCompaniesColumns[0]},
	}
	// EquipDevicesColumns holds the columns for the "equip_devices" table.
	EquipDevicesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
		{Name: "sort", Type: field.TypeUint32, Comment: "Sort Number | 排序编号", Default: 1},
		{Name: "product_key", Type: field.TypeString, Comment: "Product Key | 产品Key"},
		{Name: "iot_id", Type: field.TypeString, Unique: true, Comment: "Iot Id | 设备ID"},
		{Name: "device_name", Type: field.TypeString, Comment: "Device Name | 设备名称"},
		{Name: "device_secret", Type: field.TypeString, Nullable: true, Comment: "Device Secret | 设备密钥"},
		{Name: "device_status", Type: field.TypeString, Nullable: true, Comment: "Device Status | 设备状态"},
		{Name: "nickname", Type: field.TypeString, Nullable: true, Comment: "Nickname | 备注名称"},
		{Name: "gmt_create", Type: field.TypeString, Nullable: true, Comment: "GMT Create | GMT创建时间"},
		{Name: "gmt_modified", Type: field.TypeString, Nullable: true, Comment: "GMT Modified | GMT更新时间"},
		{Name: "utc_create", Type: field.TypeString, Nullable: true, Comment: "UTC Create | UTC创建时间"},
		{Name: "utc_modified", Type: field.TypeString, Nullable: true, Comment: "UTC Modified | UTC更新时间"},
		{Name: "operational_status_code", Type: field.TypeString, Nullable: true, Comment: "Operational Status Code | 操作状态码"},
		{Name: "operational_status", Type: field.TypeString, Nullable: true, Comment: "Operational Status | 设备实时操作状态", Default: ""},
		{Name: "tag", Type: field.TypeUint64, Nullable: true, Comment: "Tag | 标签"},
		{Name: "firmware_version", Type: field.TypeString, Nullable: true, Comment: "Firmware Version | 固件版本号"},
		{Name: "gmt_active", Type: field.TypeString, Nullable: true, Comment: "GMT Active | GMT激活时间"},
		{Name: "gmt_online", Type: field.TypeString, Nullable: true, Comment: "GMT Online | GMT最近一次上线的时间"},
		{Name: "ip_address", Type: field.TypeString, Nullable: true, Comment: "Ip Address | IP地址"},
		{Name: "node_type", Type: field.TypeInt32, Comment: "Node Type | 节点类型", Default: 0},
		{Name: "owner", Type: field.TypeBool, Nullable: true, Comment: "Owner | API调用者是否是该设备的拥有者", Default: false},
		{Name: "product_name", Type: field.TypeString, Nullable: true, Comment: "Product Name | 产品名称"},
		{Name: "region", Type: field.TypeString, Nullable: true, Comment: "Region | 所在地区"},
		{Name: "utc_active", Type: field.TypeString, Nullable: true, Comment: "UTC Active | UTC激活时间"},
		{Name: "utc_online", Type: field.TypeString, Nullable: true, Comment: "UTC Online | UTC最近一次上线的时间"},
		{Name: "product_devices", Type: field.TypeUUID, Nullable: true},
	}
	// EquipDevicesTable holds the schema information for the "equip_devices" table.
	EquipDevicesTable = &schema.Table{
		Name:       "equip_devices",
		Columns:    EquipDevicesColumns,
		PrimaryKey: []*schema.Column{EquipDevicesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "equip_devices_equip_products_devices",
				Columns:    []*schema.Column{EquipDevicesColumns[28]},
				RefColumns: []*schema.Column{EquipProductsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "device_product_key_iot_id_device_name",
				Unique:  true,
				Columns: []*schema.Column{EquipDevicesColumns[5], EquipDevicesColumns[6], EquipDevicesColumns[7]},
			},
		},
	}
	// EquipDevicePropsColumns holds the columns for the "equip_device_props" table.
	EquipDevicePropsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUint64, Increment: true},
		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
		{Name: "sort", Type: field.TypeUint32, Comment: "Sort Number | 排序编号", Default: 1},
		{Name: "iot_id", Type: field.TypeString, Comment: "Iot Id | 设备ID"},
		{Name: "props", Type: field.TypeString, Comment: "Props | 标签信息"},
		{Name: "device_prop", Type: field.TypeUUID, Unique: true, Nullable: true},
	}
	// EquipDevicePropsTable holds the schema information for the "equip_device_props" table.
	EquipDevicePropsTable = &schema.Table{
		Name:       "equip_device_props",
		Columns:    EquipDevicePropsColumns,
		PrimaryKey: []*schema.Column{EquipDevicePropsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "equip_device_props_equip_devices_prop",
				Columns:    []*schema.Column{EquipDevicePropsColumns[7]},
				RefColumns: []*schema.Column{EquipDevicesColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "deviceprop_iot_id_props",
				Unique:  true,
				Columns: []*schema.Column{EquipDevicePropsColumns[5], EquipDevicePropsColumns[6]},
			},
		},
	}
	// ClientMembersColumns holds the columns for the "client_members" table.
	ClientMembersColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
		{Name: "sort", Type: field.TypeUint32, Comment: "Sort Number | 排序编号", Default: 1},
		{Name: "company_id", Type: field.TypeUint64, Comment: "Company Id | 公司ID"},
		{Name: "type", Type: field.TypeInt32, Nullable: true, Comment: "Type | 类型", Default: 0},
		{Name: "name", Type: field.TypeString, Comment: "Name | 姓名"},
		{Name: "mobile", Type: field.TypeString, Comment: "Mobile | 手机号码"},
		{Name: "avatar", Type: field.TypeString, Nullable: true, Comment: "Avatar | 头像"},
		{Name: "account", Type: field.TypeString, Unique: true, Comment: "Account | 账号"},
		{Name: "password", Type: field.TypeString, Comment: "Password | 密码"},
		{Name: "country_code", Type: field.TypeString, Nullable: true, Comment: "Country Code | 国际区号", Default: "+86"},
		{Name: "company_members", Type: field.TypeUint64, Nullable: true},
	}
	// ClientMembersTable holds the schema information for the "client_members" table.
	ClientMembersTable = &schema.Table{
		Name:       "client_members",
		Columns:    ClientMembersColumns,
		PrimaryKey: []*schema.Column{ClientMembersColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "client_members_client_companies_members",
				Columns:    []*schema.Column{ClientMembersColumns[13]},
				RefColumns: []*schema.Column{ClientCompaniesColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "member_name_mobile_account",
				Unique:  true,
				Columns: []*schema.Column{ClientMembersColumns[7], ClientMembersColumns[8], ClientMembersColumns[10]},
			},
		},
	}
	// EquipProductsColumns holds the columns for the "equip_products" table.
	EquipProductsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
		{Name: "sort", Type: field.TypeUint32, Comment: "Sort Number | 排序编号", Default: 1},
		{Name: "product_key", Type: field.TypeString, Comment: "Product Key | 产品Key"},
		{Name: "product_name", Type: field.TypeString, Comment: "Product Name | 产品名称"},
		{Name: "auth_type", Type: field.TypeString, Nullable: true, Comment: "Auth Type | 认证方式[secret,id2,x509]"},
		{Name: "data_format", Type: field.TypeInt32, Nullable: true, Comment: "Data Format | 数据通信协议类型[0:透传模式。1:Alink JSON。]"},
		{Name: "description", Type: field.TypeString, Nullable: true, Comment: "Description | 产品描述"},
		{Name: "device_count", Type: field.TypeInt32, Comment: "Device Count | 设备数量", Default: 0},
		{Name: "gmt_create", Type: field.TypeInt64, Nullable: true, Comment: "GMT Create | GMT创建时间"},
		{Name: "node_type", Type: field.TypeInt32, Comment: "Node Type | 节点类型[0:设备。1:网关]", Default: 0},
		{Name: "aliyun_commodity_code", Type: field.TypeString, Nullable: true, Comment: "Commodity Code | 产品类型,决定是否使用物模型功能。iothub_senior:使用物模型。iothub:不使用物模型。"},
		{Name: "category_key", Type: field.TypeString, Nullable: true, Comment: "Category Key | 所属品类标识"},
		{Name: "category_name", Type: field.TypeString, Nullable: true, Comment: "Category Name | 所属品类名称"},
		{Name: "id2", Type: field.TypeBool, Nullable: true, Comment: "ID² | 该产品是否使用ID²认证", Default: false},
		{Name: "net_type", Type: field.TypeInt32, Nullable: true, Comment: "Net Type | 产品下设备的联网方式"},
		{Name: "owner", Type: field.TypeBool, Nullable: true, Comment: "Owner | 产品下设备的联网方式", Default: false},
		{Name: "product_secret", Type: field.TypeString, Nullable: true, Comment: "Product Secret | 产品密钥"},
		{Name: "product_status", Type: field.TypeString, Nullable: true, Comment: "Product Status | 产品状态"},
		{Name: "protocol_type", Type: field.TypeString, Nullable: true, Comment: "Protocol Type | 子设备接入网关的协议类型"},
		{Name: "validate_type", Type: field.TypeInt32, Nullable: true, Comment: "Validate Type | 数据校验级别"},
	}
	// EquipProductsTable holds the schema information for the "equip_products" table.
	EquipProductsTable = &schema.Table{
		Name:       "equip_products",
		Columns:    EquipProductsColumns,
		PrimaryKey: []*schema.Column{EquipProductsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "product_product_key",
				Unique:  true,
				Columns: []*schema.Column{EquipProductsColumns[5]},
			},
		},
	}
	// EquipProductEventsColumns holds the columns for the "equip_product_events" table.
	EquipProductEventsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUint64, Increment: true},
		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
		{Name: "sort", Type: field.TypeUint32, Comment: "Sort Number | 排序编号", Default: 1},
		{Name: "product_key", Type: field.TypeString, Comment: "Product Key | 产品Key"},
		{Name: "create_ts", Type: field.TypeInt64, Nullable: true, Comment: "CreateTs | 功能创建的时间戳"},
		{Name: "version", Type: field.TypeString, Nullable: true, Comment: "Version | 物模型版本号"},
		{Name: "identifier", Type: field.TypeString, Comment: "Identifier | 事件的标识符"},
		{Name: "event_name", Type: field.TypeString, Comment: "EventName | 事件名称"},
		{Name: "event_type", Type: field.TypeString, Nullable: true, Comment: "EventType | 事件类型,INFO_EVENT_TYPE:信息。ALERT_EVENT_TYPE:告警。ERROR_EVENT_TYPE:故障。", Default: "INFO_EVENT_TYPE"},
		{Name: "output_data", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "Output data | 事件的输出参数"},
		{Name: "custom", Type: field.TypeBool, Comment: "Custom | 是否是自定义功能", Default: true},
		{Name: "required", Type: field.TypeBool, Comment: "Required | 是否是标准品类的必选事件", Default: false},
		{Name: "product_events", Type: field.TypeUUID, Nullable: true},
	}
	// EquipProductEventsTable holds the schema information for the "equip_product_events" table.
	EquipProductEventsTable = &schema.Table{
		Name:       "equip_product_events",
		Columns:    EquipProductEventsColumns,
		PrimaryKey: []*schema.Column{EquipProductEventsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "equip_product_events_equip_products_events",
				Columns:    []*schema.Column{EquipProductEventsColumns[14]},
				RefColumns: []*schema.Column{EquipProductsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "productevent_product_key_identifier",
				Unique:  true,
				Columns: []*schema.Column{EquipProductEventsColumns[5], EquipProductEventsColumns[8]},
			},
		},
	}
	// EquipProductPropertiesColumns holds the columns for the "equip_product_properties" table.
	EquipProductPropertiesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUint64, Increment: true},
		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
		{Name: "sort", Type: field.TypeUint32, Comment: "Sort Number | 排序编号", Default: 1},
		{Name: "product_key", Type: field.TypeString, Comment: "Product Key | 产品Key"},
		{Name: "version", Type: field.TypeString, Nullable: true, Comment: "Version | 物模型版本号"},
		{Name: "create_ts", Type: field.TypeInt64, Nullable: true, Comment: "CreateTs | 功能创建的时间戳"},
		{Name: "identifier", Type: field.TypeString, Comment: "Identifier | 属性的标识符"},
		{Name: "name", Type: field.TypeString, Comment: "Name | 属性名称"},
		{Name: "rw_flag", Type: field.TypeString, Comment: "RWFlag | 在云端可以对该属性进行的操作类型", Default: "READ_WRITE"},
		{Name: "required", Type: field.TypeBool, Comment: "Required | 是否是标准品类的必选属性", Default: false},
		{Name: "data_type", Type: field.TypeString, Nullable: true, Comment: "Data Type | 属性值的数据类型,可选值:ARRAY、STRUCT、INT、FLOAT、DOUBLE、TEXT、DATE、ENUM、BOOL。"},
		{Name: "data_specs", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "Data Specs | 数据类型(dataType)为非列表型(INT、FLOAT、DOUBLE、TEXT、DATE、ARRAY)的数据规范存储在dataSpecs中"},
		{Name: "data_specs_list", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "Data Specs List | 数据类型(dataType)为列表型(ENUM、BOOL、STRUCT)的数据规范存储在dataSpecsList中"},
		{Name: "custom", Type: field.TypeBool, Comment: "Custom | 是否是自定义功能", Default: true},
		{Name: "product_properties", Type: field.TypeUUID, Nullable: true},
	}
	// EquipProductPropertiesTable holds the schema information for the "equip_product_properties" table.
	EquipProductPropertiesTable = &schema.Table{
		Name:       "equip_product_properties",
		Columns:    EquipProductPropertiesColumns,
		PrimaryKey: []*schema.Column{EquipProductPropertiesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "equip_product_properties_equip_products_properties",
				Columns:    []*schema.Column{EquipProductPropertiesColumns[16]},
				RefColumns: []*schema.Column{EquipProductsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "productproperty_product_key_identifier",
				Unique:  true,
				Columns: []*schema.Column{EquipProductPropertiesColumns[5], EquipProductPropertiesColumns[8]},
			},
		},
	}
	// EquipProductServicesColumns holds the columns for the "equip_product_services" table.
	EquipProductServicesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUint64, Increment: true},
		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
		{Name: "sort", Type: field.TypeUint32, Comment: "Sort Number | 排序编号", Default: 1},
		{Name: "product_key", Type: field.TypeString, Comment: "Product Key | 产品Key"},
		{Name: "create_ts", Type: field.TypeInt64, Nullable: true, Comment: "CreateTs | 功能创建的时间戳"},
		{Name: "version", Type: field.TypeString, Nullable: true, Comment: "Version | 物模型版本号"},
		{Name: "identifier", Type: field.TypeString, Comment: "Identifier | 服务的标识符"},
		{Name: "service_name", Type: field.TypeString, Comment: "ServiceName | 服务名称"},
		{Name: "input_params", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "InputParams | 服务的输入参数"},
		{Name: "output_params", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "OutputParams | 服务的输出参数"},
		{Name: "required", Type: field.TypeBool, Comment: "Required | 是否是标准品类的必选事件", Default: false},
		{Name: "call_type", Type: field.TypeString, Comment: "CallType | 服务的调用方式", Default: "ASYNC"},
		{Name: "custom", Type: field.TypeBool, Comment: "Custom | 是否是自定义功能", Default: true},
		{Name: "product_services", Type: field.TypeUUID, Nullable: true},
	}
	// EquipProductServicesTable holds the schema information for the "equip_product_services" table.
	EquipProductServicesTable = &schema.Table{
		Name:       "equip_product_services",
		Columns:    EquipProductServicesColumns,
		PrimaryKey: []*schema.Column{EquipProductServicesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "equip_product_services_equip_products_services",
				Columns:    []*schema.Column{EquipProductServicesColumns[15]},
				RefColumns: []*schema.Column{EquipProductsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "productservice_product_key_identifier",
				Unique:  true,
				Columns: []*schema.Column{EquipProductServicesColumns[5], EquipProductServicesColumns[8]},
			},
		},
	}
	// EquipProductTagsColumns holds the columns for the "equip_product_tags" table.
	EquipProductTagsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUint64, Increment: true},
		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
		{Name: "sort", Type: field.TypeUint32, Comment: "Sort Number | 排序编号", Default: 1},
		{Name: "product_key", Type: field.TypeString, Comment: "Product Key | 产品Key"},
		{Name: "tag_key", Type: field.TypeString, Comment: "Tag Key | 标签键"},
		{Name: "tag_value", Type: field.TypeString, Comment: "Tag Value | 标签值"},
		{Name: "product_tags", Type: field.TypeUUID, Nullable: true},
	}
	// EquipProductTagsTable holds the schema information for the "equip_product_tags" table.
	EquipProductTagsTable = &schema.Table{
		Name:       "equip_product_tags",
		Columns:    EquipProductTagsColumns,
		PrimaryKey: []*schema.Column{EquipProductTagsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "equip_product_tags_equip_products_tags",
				Columns:    []*schema.Column{EquipProductTagsColumns[8]},
				RefColumns: []*schema.Column{EquipProductsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "producttag_product_key_tag_key",
				Unique:  true,
				Columns: []*schema.Column{EquipProductTagsColumns[5], EquipProductTagsColumns[6]},
			},
		},
	}
	// CompanyDevicesColumns holds the columns for the "company_devices" table.
	CompanyDevicesColumns = []*schema.Column{
		{Name: "company_id", Type: field.TypeUint64},
		{Name: "device_id", Type: field.TypeUUID},
	}
	// CompanyDevicesTable holds the schema information for the "company_devices" table.
	CompanyDevicesTable = &schema.Table{
		Name:       "company_devices",
		Columns:    CompanyDevicesColumns,
		PrimaryKey: []*schema.Column{CompanyDevicesColumns[0], CompanyDevicesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "company_devices_company_id",
				Columns:    []*schema.Column{CompanyDevicesColumns[0]},
				RefColumns: []*schema.Column{ClientCompaniesColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "company_devices_device_id",
				Columns:    []*schema.Column{CompanyDevicesColumns[1]},
				RefColumns: []*schema.Column{EquipDevicesColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// MemberDevicesColumns holds the columns for the "member_devices" table.
	MemberDevicesColumns = []*schema.Column{
		{Name: "member_id", Type: field.TypeUUID},
		{Name: "device_id", Type: field.TypeUUID},
	}
	// MemberDevicesTable holds the schema information for the "member_devices" table.
	MemberDevicesTable = &schema.Table{
		Name:       "member_devices",
		Columns:    MemberDevicesColumns,
		PrimaryKey: []*schema.Column{MemberDevicesColumns[0], MemberDevicesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "member_devices_member_id",
				Columns:    []*schema.Column{MemberDevicesColumns[0]},
				RefColumns: []*schema.Column{ClientMembersColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "member_devices_device_id",
				Columns:    []*schema.Column{MemberDevicesColumns[1]},
				RefColumns: []*schema.Column{EquipDevicesColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		ClientCompaniesTable,
		EquipDevicesTable,
		EquipDevicePropsTable,
		ClientMembersTable,
		EquipProductsTable,
		EquipProductEventsTable,
		EquipProductPropertiesTable,
		EquipProductServicesTable,
		EquipProductTagsTable,
		CompanyDevicesTable,
		MemberDevicesTable,
	}
)

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