migrate

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 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 (
	// SfAPIKeysColumns holds the columns for the "sf_api_keys" table.
	SfAPIKeysColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "name", Type: field.TypeString},
		{Name: "prefix", Type: field.TypeString, Unique: true},
		{Name: "key_hash", Type: field.TypeString},
		{Name: "scopes", Type: field.TypeJSON, Nullable: true},
		{Name: "description", Type: field.TypeString, Nullable: true},
		{Name: "expires_at", Type: field.TypeTime, Nullable: true},
		{Name: "last_used_at", Type: field.TypeTime, Nullable: true},
		{Name: "last_used_ip", Type: field.TypeString, Nullable: true},
		{Name: "revoked", Type: field.TypeBool, Default: false},
		{Name: "revoked_at", Type: field.TypeTime, Nullable: true},
		{Name: "revoked_reason", Type: field.TypeString, Nullable: true},
		{Name: "environment", Type: field.TypeEnum, Enums: []string{"live", "test"}, Default: "live"},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "organization_api_keys", Type: field.TypeUUID, Nullable: true},
		{Name: "user_api_keys", Type: field.TypeUUID},
	}
	// SfAPIKeysTable holds the schema information for the "sf_api_keys" table.
	SfAPIKeysTable = &schema.Table{
		Name:       "sf_api_keys",
		Columns:    SfAPIKeysColumns,
		PrimaryKey: []*schema.Column{SfAPIKeysColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_api_keys_sf_organizations_api_keys",
				Columns:    []*schema.Column{SfAPIKeysColumns[16]},
				RefColumns: []*schema.Column{SfOrganizationsColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "sf_api_keys_sf_users_api_keys",
				Columns:    []*schema.Column{SfAPIKeysColumns[17]},
				RefColumns: []*schema.Column{SfUsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "apikey_prefix",
				Unique:  true,
				Columns: []*schema.Column{SfAPIKeysColumns[4]},
			},
			{
				Name:    "apikey_user_api_keys",
				Unique:  false,
				Columns: []*schema.Column{SfAPIKeysColumns[17]},
			},
			{
				Name:    "apikey_organization_api_keys",
				Unique:  false,
				Columns: []*schema.Column{SfAPIKeysColumns[16]},
			},
			{
				Name:    "apikey_revoked_expires_at",
				Unique:  false,
				Columns: []*schema.Column{SfAPIKeysColumns[11], SfAPIKeysColumns[8]},
			},
			{
				Name:    "apikey_environment",
				Unique:  false,
				Columns: []*schema.Column{SfAPIKeysColumns[14]},
			},
		},
	}
	// SfAgentsColumns holds the columns for the "sf_agents" table.
	SfAgentsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "model_id", Type: field.TypeString},
		{Name: "version", Type: field.TypeString, Nullable: true},
		{Name: "capability_constraints", Type: field.TypeJSON},
		{Name: "resource_constraints", Type: field.TypeJSON},
		{Name: "max_token_lifetime", Type: field.TypeInt, Default: 3600},
		{Name: "session_id", Type: field.TypeString, Nullable: true},
		{Name: "requires_confirmation", Type: field.TypeBool, Default: true},
		{Name: "delegating_principal_id", Type: field.TypeUUID, Nullable: true},
		{Name: "principal_id", Type: field.TypeUUID, Unique: true},
	}
	// SfAgentsTable holds the schema information for the "sf_agents" table.
	SfAgentsTable = &schema.Table{
		Name:       "sf_agents",
		Columns:    SfAgentsColumns,
		PrimaryKey: []*schema.Column{SfAgentsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_agents_sf_principals_delegating_principal",
				Columns:    []*schema.Column{SfAgentsColumns[10]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "sf_agents_sf_principals_agent",
				Columns:    []*schema.Column{SfAgentsColumns[11]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "agent_principal_id",
				Unique:  true,
				Columns: []*schema.Column{SfAgentsColumns[11]},
			},
			{
				Name:    "agent_model_id",
				Unique:  false,
				Columns: []*schema.Column{SfAgentsColumns[3]},
			},
			{
				Name:    "agent_delegating_principal_id",
				Unique:  false,
				Columns: []*schema.Column{SfAgentsColumns[10]},
			},
			{
				Name:    "agent_session_id",
				Unique:  false,
				Columns: []*schema.Column{SfAgentsColumns[8]},
			},
			{
				Name:    "agent_requires_confirmation",
				Unique:  false,
				Columns: []*schema.Column{SfAgentsColumns[9]},
			},
		},
	}
	// SfApplicationsColumns holds the columns for the "sf_applications" table.
	SfApplicationsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "client_id", Type: field.TypeString, Unique: true},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
		{Name: "logo_url", Type: field.TypeString, Nullable: true},
		{Name: "app_type", Type: field.TypeEnum, Enums: []string{"web", "spa", "native", "machine"}, Default: "web"},
		{Name: "redirect_uris", Type: field.TypeJSON},
		{Name: "allowed_grants", Type: field.TypeJSON},
		{Name: "allowed_response_types", Type: field.TypeJSON},
		{Name: "access_token_ttl", Type: field.TypeInt, Default: 900},
		{Name: "refresh_token_ttl", Type: field.TypeInt, Default: 604800},
		{Name: "refresh_token_rotation", Type: field.TypeBool, Default: true},
		{Name: "first_party", Type: field.TypeBool, Default: false},
		{Name: "public", Type: field.TypeBool, Default: false},
		{Name: "principal_id", Type: field.TypeUUID, Unique: true},
	}
	// SfApplicationsTable holds the schema information for the "sf_applications" table.
	SfApplicationsTable = &schema.Table{
		Name:       "sf_applications",
		Columns:    SfApplicationsColumns,
		PrimaryKey: []*schema.Column{SfApplicationsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_applications_sf_principals_application",
				Columns:    []*schema.Column{SfApplicationsColumns[15]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "application_principal_id",
				Unique:  true,
				Columns: []*schema.Column{SfApplicationsColumns[15]},
			},
			{
				Name:    "application_client_id",
				Unique:  true,
				Columns: []*schema.Column{SfApplicationsColumns[3]},
			},
			{
				Name:    "application_app_type",
				Unique:  false,
				Columns: []*schema.Column{SfApplicationsColumns[6]},
			},
			{
				Name:    "application_first_party",
				Unique:  false,
				Columns: []*schema.Column{SfApplicationsColumns[13]},
			},
		},
	}
	// SfCredentialsColumns holds the columns for the "sf_credentials" table.
	SfCredentialsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "type", Type: field.TypeEnum, Enums: []string{"password", "api_key", "keypair", "webauthn", "totp", "client_secret"}},
		{Name: "identifier", Type: field.TypeString, Nullable: true},
		{Name: "secret_hash", Type: field.TypeString, Nullable: true},
		{Name: "public_key", Type: field.TypeString, Nullable: true, Size: 2147483647},
		{Name: "key_algorithm", Type: field.TypeString, Nullable: true},
		{Name: "key_id", Type: field.TypeString, Unique: true, Nullable: true},
		{Name: "webauthn_credential_id", Type: field.TypeBytes, Nullable: true},
		{Name: "webauthn_public_key", Type: field.TypeBytes, Nullable: true},
		{Name: "webauthn_aaguid", Type: field.TypeString, Nullable: true},
		{Name: "webauthn_sign_count", Type: field.TypeUint32, Nullable: true, Default: 0},
		{Name: "scopes", Type: field.TypeJSON},
		{Name: "active", Type: field.TypeBool, Default: true},
		{Name: "expires_at", Type: field.TypeTime, Nullable: true},
		{Name: "revoked", Type: field.TypeBool, Default: false},
		{Name: "revoked_at", Type: field.TypeTime, Nullable: true},
		{Name: "revoked_reason", Type: field.TypeString, Nullable: true},
		{Name: "last_used_at", Type: field.TypeTime, Nullable: true},
		{Name: "last_used_ip", Type: field.TypeString, Nullable: true},
		{Name: "name", Type: field.TypeString, Nullable: true},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "principal_id", Type: field.TypeUUID},
	}
	// SfCredentialsTable holds the schema information for the "sf_credentials" table.
	SfCredentialsTable = &schema.Table{
		Name:       "sf_credentials",
		Columns:    SfCredentialsColumns,
		PrimaryKey: []*schema.Column{SfCredentialsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_credentials_sf_principals_credentials",
				Columns:    []*schema.Column{SfCredentialsColumns[23]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "credential_principal_id",
				Unique:  false,
				Columns: []*schema.Column{SfCredentialsColumns[23]},
			},
			{
				Name:    "credential_principal_id_type",
				Unique:  false,
				Columns: []*schema.Column{SfCredentialsColumns[23], SfCredentialsColumns[1]},
			},
			{
				Name:    "credential_type",
				Unique:  false,
				Columns: []*schema.Column{SfCredentialsColumns[1]},
			},
			{
				Name:    "credential_identifier",
				Unique:  false,
				Columns: []*schema.Column{SfCredentialsColumns[2]},
			},
			{
				Name:    "credential_active",
				Unique:  false,
				Columns: []*schema.Column{SfCredentialsColumns[12]},
			},
			{
				Name:    "credential_revoked",
				Unique:  false,
				Columns: []*schema.Column{SfCredentialsColumns[14]},
			},
			{
				Name:    "credential_expires_at",
				Unique:  false,
				Columns: []*schema.Column{SfCredentialsColumns[13]},
			},
			{
				Name:    "credential_type_identifier",
				Unique:  true,
				Columns: []*schema.Column{SfCredentialsColumns[1], SfCredentialsColumns[2]},
			},
		},
	}
	// SfHumansColumns holds the columns for the "sf_humans" table.
	SfHumansColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "email", Type: field.TypeString, Unique: true},
		{Name: "given_name", Type: field.TypeString, Nullable: true},
		{Name: "family_name", Type: field.TypeString, Nullable: true},
		{Name: "avatar_url", Type: field.TypeString, Nullable: true},
		{Name: "locale", Type: field.TypeString, Nullable: true, Default: "en"},
		{Name: "timezone", Type: field.TypeString, Nullable: true, Default: "UTC"},
		{Name: "is_platform_admin", Type: field.TypeBool, Default: false},
		{Name: "last_login_at", Type: field.TypeTime, Nullable: true},
		{Name: "email_verified_at", Type: field.TypeTime, Nullable: true},
		{Name: "principal_id", Type: field.TypeUUID, Unique: true},
	}
	// SfHumansTable holds the schema information for the "sf_humans" table.
	SfHumansTable = &schema.Table{
		Name:       "sf_humans",
		Columns:    SfHumansColumns,
		PrimaryKey: []*schema.Column{SfHumansColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_humans_sf_principals_human",
				Columns:    []*schema.Column{SfHumansColumns[12]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "human_principal_id",
				Unique:  true,
				Columns: []*schema.Column{SfHumansColumns[12]},
			},
			{
				Name:    "human_email",
				Unique:  true,
				Columns: []*schema.Column{SfHumansColumns[3]},
			},
			{
				Name:    "human_is_platform_admin",
				Unique:  false,
				Columns: []*schema.Column{SfHumansColumns[9]},
			},
		},
	}
	// SfInvitesColumns holds the columns for the "sf_invites" table.
	SfInvitesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "email", Type: field.TypeString},
		{Name: "role", Type: field.TypeString, Default: "member"},
		{Name: "token", Type: field.TypeString, Unique: true},
		{Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "accepted", "declined", "expired", "revoked"}, Default: "pending"},
		{Name: "message", Type: field.TypeString, Nullable: true, Size: 2147483647},
		{Name: "expires_at", Type: field.TypeTime},
		{Name: "accepted_at", Type: field.TypeTime, Nullable: true},
		{Name: "accepted_by_principal_id", Type: field.TypeUUID, Nullable: true},
		{Name: "resend_count", Type: field.TypeInt, Default: 0},
		{Name: "last_sent_at", Type: field.TypeTime},
		{Name: "organization_id", Type: field.TypeUUID},
		{Name: "inviter_principal_id", Type: field.TypeUUID},
	}
	// SfInvitesTable holds the schema information for the "sf_invites" table.
	SfInvitesTable = &schema.Table{
		Name:       "sf_invites",
		Columns:    SfInvitesColumns,
		PrimaryKey: []*schema.Column{SfInvitesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_invites_sf_organizations_invites",
				Columns:    []*schema.Column{SfInvitesColumns[13]},
				RefColumns: []*schema.Column{SfOrganizationsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_invites_sf_principals_sent_invites",
				Columns:    []*schema.Column{SfInvitesColumns[14]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "invite_token",
				Unique:  true,
				Columns: []*schema.Column{SfInvitesColumns[5]},
			},
			{
				Name:    "invite_email",
				Unique:  false,
				Columns: []*schema.Column{SfInvitesColumns[3]},
			},
			{
				Name:    "invite_organization_id",
				Unique:  false,
				Columns: []*schema.Column{SfInvitesColumns[13]},
			},
			{
				Name:    "invite_organization_id_status",
				Unique:  false,
				Columns: []*schema.Column{SfInvitesColumns[13], SfInvitesColumns[6]},
			},
			{
				Name:    "invite_organization_id_email_status",
				Unique:  false,
				Columns: []*schema.Column{SfInvitesColumns[13], SfInvitesColumns[3], SfInvitesColumns[6]},
			},
			{
				Name:    "invite_inviter_principal_id",
				Unique:  false,
				Columns: []*schema.Column{SfInvitesColumns[14]},
			},
			{
				Name:    "invite_status_expires_at",
				Unique:  false,
				Columns: []*schema.Column{SfInvitesColumns[6], SfInvitesColumns[8]},
			},
		},
	}
	// SfLicensesColumns holds the columns for the "sf_licenses" table.
	SfLicensesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "license_type", Type: field.TypeEnum, Enums: []string{"seat_based", "team", "unlimited"}, Default: "unlimited"},
		{Name: "seats", Type: field.TypeInt, Nullable: true},
		{Name: "used_seats", Type: field.TypeInt, Default: 0},
		{Name: "valid_from", Type: field.TypeTime},
		{Name: "valid_until", Type: field.TypeTime, Nullable: true},
		{Name: "stripe_subscription_id", Type: field.TypeString, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "listing_id", Type: field.TypeUUID},
		{Name: "organization_id", Type: field.TypeUUID},
		{Name: "purchased_by", Type: field.TypeUUID},
	}
	// SfLicensesTable holds the schema information for the "sf_licenses" table.
	SfLicensesTable = &schema.Table{
		Name:       "sf_licenses",
		Columns:    SfLicensesColumns,
		PrimaryKey: []*schema.Column{SfLicensesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_licenses_sf_listings_licenses",
				Columns:    []*schema.Column{SfLicensesColumns[9]},
				RefColumns: []*schema.Column{SfListingsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_licenses_sf_organizations_licenses",
				Columns:    []*schema.Column{SfLicensesColumns[10]},
				RefColumns: []*schema.Column{SfOrganizationsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_licenses_sf_principals_purchased_licenses",
				Columns:    []*schema.Column{SfLicensesColumns[11]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "license_listing_id",
				Unique:  false,
				Columns: []*schema.Column{SfLicensesColumns[9]},
			},
			{
				Name:    "license_organization_id",
				Unique:  false,
				Columns: []*schema.Column{SfLicensesColumns[10]},
			},
			{
				Name:    "license_purchased_by",
				Unique:  false,
				Columns: []*schema.Column{SfLicensesColumns[11]},
			},
			{
				Name:    "license_license_type",
				Unique:  false,
				Columns: []*schema.Column{SfLicensesColumns[1]},
			},
			{
				Name:    "license_valid_from_valid_until",
				Unique:  false,
				Columns: []*schema.Column{SfLicensesColumns[4], SfLicensesColumns[5]},
			},
			{
				Name:    "license_stripe_subscription_id",
				Unique:  false,
				Columns: []*schema.Column{SfLicensesColumns[6]},
			},
			{
				Name:    "license_listing_id_organization_id",
				Unique:  true,
				Columns: []*schema.Column{SfLicensesColumns[9], SfLicensesColumns[10]},
			},
		},
	}
	// SfListingsColumns holds the columns for the "sf_listings" table.
	SfListingsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "product_type", Type: field.TypeString},
		{Name: "product_id", Type: field.TypeUUID, Nullable: true},
		{Name: "title", Type: field.TypeString, Size: 200},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647},
		{Name: "pricing_model", Type: field.TypeEnum, Enums: []string{"free", "one_time", "subscription", "per_seat"}, Default: "free"},
		{Name: "price_cents", Type: field.TypeInt64, Default: 0},
		{Name: "currency", Type: field.TypeString, Size: 3, Default: "USD"},
		{Name: "status", Type: field.TypeEnum, Enums: []string{"draft", "pending_review", "published", "archived"}, Default: "draft"},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "published_at", Type: field.TypeTime, Nullable: true},
		{Name: "creator_org_id", Type: field.TypeUUID},
		{Name: "owner_id", Type: field.TypeUUID},
	}
	// SfListingsTable holds the schema information for the "sf_listings" table.
	SfListingsTable = &schema.Table{
		Name:       "sf_listings",
		Columns:    SfListingsColumns,
		PrimaryKey: []*schema.Column{SfListingsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_listings_sf_organizations_listings",
				Columns:    []*schema.Column{SfListingsColumns[13]},
				RefColumns: []*schema.Column{SfOrganizationsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_listings_sf_principals_owned_listings",
				Columns:    []*schema.Column{SfListingsColumns[14]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "listing_creator_org_id",
				Unique:  false,
				Columns: []*schema.Column{SfListingsColumns[13]},
			},
			{
				Name:    "listing_owner_id",
				Unique:  false,
				Columns: []*schema.Column{SfListingsColumns[14]},
			},
			{
				Name:    "listing_status",
				Unique:  false,
				Columns: []*schema.Column{SfListingsColumns[8]},
			},
			{
				Name:    "listing_pricing_model",
				Unique:  false,
				Columns: []*schema.Column{SfListingsColumns[5]},
			},
			{
				Name:    "listing_product_type",
				Unique:  false,
				Columns: []*schema.Column{SfListingsColumns[1]},
			},
			{
				Name:    "listing_product_type_product_id",
				Unique:  false,
				Columns: []*schema.Column{SfListingsColumns[1], SfListingsColumns[2]},
			},
			{
				Name:    "listing_status_created_at",
				Unique:  false,
				Columns: []*schema.Column{SfListingsColumns[8], SfListingsColumns[10]},
			},
		},
	}
	// SfMembershipsColumns holds the columns for the "sf_memberships" table.
	SfMembershipsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "role", Type: field.TypeString},
		{Name: "permissions", Type: field.TypeJSON, Nullable: true},
		{Name: "organization_id", Type: field.TypeUUID},
		{Name: "user_id", Type: field.TypeUUID},
	}
	// SfMembershipsTable holds the schema information for the "sf_memberships" table.
	SfMembershipsTable = &schema.Table{
		Name:       "sf_memberships",
		Columns:    SfMembershipsColumns,
		PrimaryKey: []*schema.Column{SfMembershipsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_memberships_sf_organizations_memberships",
				Columns:    []*schema.Column{SfMembershipsColumns[5]},
				RefColumns: []*schema.Column{SfOrganizationsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_memberships_sf_users_memberships",
				Columns:    []*schema.Column{SfMembershipsColumns[6]},
				RefColumns: []*schema.Column{SfUsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "membership_user_id_organization_id",
				Unique:  true,
				Columns: []*schema.Column{SfMembershipsColumns[6], SfMembershipsColumns[5]},
			},
			{
				Name:    "membership_user_id",
				Unique:  false,
				Columns: []*schema.Column{SfMembershipsColumns[6]},
			},
			{
				Name:    "membership_organization_id",
				Unique:  false,
				Columns: []*schema.Column{SfMembershipsColumns[5]},
			},
			{
				Name:    "membership_role",
				Unique:  false,
				Columns: []*schema.Column{SfMembershipsColumns[3]},
			},
		},
	}
	// SfOauthAccountsColumns holds the columns for the "sf_oauth_accounts" table.
	SfOauthAccountsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "provider", Type: field.TypeString},
		{Name: "provider_user_id", Type: field.TypeString},
		{Name: "access_token", Type: field.TypeString, Nullable: true},
		{Name: "refresh_token", Type: field.TypeString, Nullable: true},
		{Name: "token_expires_at", Type: field.TypeTime, Nullable: true},
		{Name: "user_id", Type: field.TypeUUID},
	}
	// SfOauthAccountsTable holds the schema information for the "sf_oauth_accounts" table.
	SfOauthAccountsTable = &schema.Table{
		Name:       "sf_oauth_accounts",
		Columns:    SfOauthAccountsColumns,
		PrimaryKey: []*schema.Column{SfOauthAccountsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_oauth_accounts_sf_users_oauth_accounts",
				Columns:    []*schema.Column{SfOauthAccountsColumns[8]},
				RefColumns: []*schema.Column{SfUsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "oauthaccount_provider_provider_user_id",
				Unique:  true,
				Columns: []*schema.Column{SfOauthAccountsColumns[3], SfOauthAccountsColumns[4]},
			},
			{
				Name:    "oauthaccount_user_id",
				Unique:  false,
				Columns: []*schema.Column{SfOauthAccountsColumns[8]},
			},
			{
				Name:    "oauthaccount_provider",
				Unique:  false,
				Columns: []*schema.Column{SfOauthAccountsColumns[3]},
			},
		},
	}
	// SfOauthAppsColumns holds the columns for the "sf_oauth_apps" table.
	SfOauthAppsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "client_id", Type: field.TypeString, Unique: true},
		{Name: "name", Type: field.TypeString, Size: 255},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
		{Name: "logo_url", Type: field.TypeString, Nullable: true},
		{Name: "app_type", Type: field.TypeEnum, Enums: []string{"web", "spa", "native", "service", "machine"}, Default: "web"},
		{Name: "redirect_uris", Type: field.TypeJSON},
		{Name: "allowed_scopes", Type: field.TypeJSON},
		{Name: "allowed_grants", Type: field.TypeJSON},
		{Name: "allowed_response_types", Type: field.TypeJSON},
		{Name: "access_token_ttl", Type: field.TypeInt, Default: 900},
		{Name: "refresh_token_ttl", Type: field.TypeInt, Default: 604800},
		{Name: "refresh_token_rotation", Type: field.TypeBool, Default: true},
		{Name: "first_party", Type: field.TypeBool, Default: false},
		{Name: "public", Type: field.TypeBool, Default: false},
		{Name: "active", Type: field.TypeBool, Default: true},
		{Name: "revoked_at", Type: field.TypeTime, Nullable: true},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "organization_id", Type: field.TypeUUID, Nullable: true},
		{Name: "owner_id", Type: field.TypeUUID},
	}
	// SfOauthAppsTable holds the schema information for the "sf_oauth_apps" table.
	SfOauthAppsTable = &schema.Table{
		Name:       "sf_oauth_apps",
		Columns:    SfOauthAppsColumns,
		PrimaryKey: []*schema.Column{SfOauthAppsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_oauth_apps_sf_organizations_oauth_apps",
				Columns:    []*schema.Column{SfOauthAppsColumns[20]},
				RefColumns: []*schema.Column{SfOrganizationsColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "sf_oauth_apps_sf_users_oauth_apps",
				Columns:    []*schema.Column{SfOauthAppsColumns[21]},
				RefColumns: []*schema.Column{SfUsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "oauthapp_client_id",
				Unique:  true,
				Columns: []*schema.Column{SfOauthAppsColumns[1]},
			},
			{
				Name:    "oauthapp_owner_id",
				Unique:  false,
				Columns: []*schema.Column{SfOauthAppsColumns[21]},
			},
			{
				Name:    "oauthapp_organization_id",
				Unique:  false,
				Columns: []*schema.Column{SfOauthAppsColumns[20]},
			},
			{
				Name:    "oauthapp_active",
				Unique:  false,
				Columns: []*schema.Column{SfOauthAppsColumns[15]},
			},
		},
	}
	// SfOauthAppSecretsColumns holds the columns for the "sf_oauth_app_secrets" table.
	SfOauthAppSecretsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "secret_hash", Type: field.TypeString},
		{Name: "secret_prefix", Type: field.TypeString, Size: 12},
		{Name: "expires_at", Type: field.TypeTime, Nullable: true},
		{Name: "last_used_at", Type: field.TypeTime, Nullable: true},
		{Name: "revoked", Type: field.TypeBool, Default: false},
		{Name: "revoked_at", Type: field.TypeTime, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "app_id", Type: field.TypeUUID},
	}
	// SfOauthAppSecretsTable holds the schema information for the "sf_oauth_app_secrets" table.
	SfOauthAppSecretsTable = &schema.Table{
		Name:       "sf_oauth_app_secrets",
		Columns:    SfOauthAppSecretsColumns,
		PrimaryKey: []*schema.Column{SfOauthAppSecretsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_oauth_app_secrets_sf_oauth_apps_secrets",
				Columns:    []*schema.Column{SfOauthAppSecretsColumns[8]},
				RefColumns: []*schema.Column{SfOauthAppsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "oauthappsecret_app_id",
				Unique:  false,
				Columns: []*schema.Column{SfOauthAppSecretsColumns[8]},
			},
			{
				Name:    "oauthappsecret_app_id_revoked",
				Unique:  false,
				Columns: []*schema.Column{SfOauthAppSecretsColumns[8], SfOauthAppSecretsColumns[5]},
			},
		},
	}
	// SfOauthAuthCodesColumns holds the columns for the "sf_oauth_auth_codes" table.
	SfOauthAuthCodesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "code_signature", Type: field.TypeString, Unique: true},
		{Name: "code_challenge", Type: field.TypeString, Nullable: true},
		{Name: "code_challenge_method", Type: field.TypeString, Nullable: true, Default: "S256"},
		{Name: "redirect_uri", Type: field.TypeString},
		{Name: "scopes", Type: field.TypeJSON},
		{Name: "state", Type: field.TypeString, Nullable: true},
		{Name: "nonce", Type: field.TypeString, Nullable: true},
		{Name: "request_data", Type: field.TypeString, Nullable: true, Size: 2147483647},
		{Name: "expires_at", Type: field.TypeTime},
		{Name: "used", Type: field.TypeBool, Default: false},
		{Name: "used_at", Type: field.TypeTime, Nullable: true},
		{Name: "client_ip", Type: field.TypeString, Nullable: true},
		{Name: "user_agent", Type: field.TypeString, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "app_id", Type: field.TypeUUID},
		{Name: "user_id", Type: field.TypeUUID},
	}
	// SfOauthAuthCodesTable holds the schema information for the "sf_oauth_auth_codes" table.
	SfOauthAuthCodesTable = &schema.Table{
		Name:       "sf_oauth_auth_codes",
		Columns:    SfOauthAuthCodesColumns,
		PrimaryKey: []*schema.Column{SfOauthAuthCodesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_oauth_auth_codes_sf_oauth_apps_auth_codes",
				Columns:    []*schema.Column{SfOauthAuthCodesColumns[15]},
				RefColumns: []*schema.Column{SfOauthAppsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_oauth_auth_codes_sf_users_oauth_auth_codes",
				Columns:    []*schema.Column{SfOauthAuthCodesColumns[16]},
				RefColumns: []*schema.Column{SfUsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "oauthauthcode_code_signature",
				Unique:  true,
				Columns: []*schema.Column{SfOauthAuthCodesColumns[1]},
			},
			{
				Name:    "oauthauthcode_app_id",
				Unique:  false,
				Columns: []*schema.Column{SfOauthAuthCodesColumns[15]},
			},
			{
				Name:    "oauthauthcode_user_id",
				Unique:  false,
				Columns: []*schema.Column{SfOauthAuthCodesColumns[16]},
			},
			{
				Name:    "oauthauthcode_expires_at",
				Unique:  false,
				Columns: []*schema.Column{SfOauthAuthCodesColumns[9]},
			},
			{
				Name:    "oauthauthcode_used",
				Unique:  false,
				Columns: []*schema.Column{SfOauthAuthCodesColumns[10]},
			},
		},
	}
	// SfOauthConsentsColumns holds the columns for the "sf_oauth_consents" table.
	SfOauthConsentsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "scopes", Type: field.TypeJSON},
		{Name: "granted", Type: field.TypeBool, Default: true},
		{Name: "granted_at", Type: field.TypeTime},
		{Name: "last_used_at", Type: field.TypeTime, Nullable: true},
		{Name: "revoked", Type: field.TypeBool, Default: false},
		{Name: "revoked_at", Type: field.TypeTime, Nullable: true},
		{Name: "revoked_reason", Type: field.TypeString, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "app_id", Type: field.TypeUUID},
		{Name: "user_id", Type: field.TypeUUID},
	}
	// SfOauthConsentsTable holds the schema information for the "sf_oauth_consents" table.
	SfOauthConsentsTable = &schema.Table{
		Name:       "sf_oauth_consents",
		Columns:    SfOauthConsentsColumns,
		PrimaryKey: []*schema.Column{SfOauthConsentsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_oauth_consents_sf_oauth_apps_consents",
				Columns:    []*schema.Column{SfOauthConsentsColumns[10]},
				RefColumns: []*schema.Column{SfOauthAppsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_oauth_consents_sf_users_oauth_consents",
				Columns:    []*schema.Column{SfOauthConsentsColumns[11]},
				RefColumns: []*schema.Column{SfUsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "oauthconsent_user_id_app_id",
				Unique:  true,
				Columns: []*schema.Column{SfOauthConsentsColumns[11], SfOauthConsentsColumns[10]},
			},
			{
				Name:    "oauthconsent_user_id",
				Unique:  false,
				Columns: []*schema.Column{SfOauthConsentsColumns[11]},
			},
			{
				Name:    "oauthconsent_app_id",
				Unique:  false,
				Columns: []*schema.Column{SfOauthConsentsColumns[10]},
			},
			{
				Name:    "oauthconsent_granted",
				Unique:  false,
				Columns: []*schema.Column{SfOauthConsentsColumns[2]},
			},
			{
				Name:    "oauthconsent_revoked",
				Unique:  false,
				Columns: []*schema.Column{SfOauthConsentsColumns[5]},
			},
		},
	}
	// SfOauthTokensColumns holds the columns for the "sf_oauth_tokens" table.
	SfOauthTokensColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "service_account_id", Type: field.TypeUUID, Nullable: true},
		{Name: "access_token_signature", Type: field.TypeString, Unique: true},
		{Name: "refresh_token_signature", Type: field.TypeString, Unique: true, Nullable: true},
		{Name: "family_id", Type: field.TypeUUID},
		{Name: "scopes", Type: field.TypeJSON},
		{Name: "audience", Type: field.TypeJSON},
		{Name: "session_id", Type: field.TypeString, Nullable: true},
		{Name: "request_data", Type: field.TypeString, Nullable: true, Size: 2147483647},
		{Name: "access_expires_at", Type: field.TypeTime},
		{Name: "refresh_expires_at", Type: field.TypeTime, Nullable: true},
		{Name: "revoked", Type: field.TypeBool, Default: false},
		{Name: "revoked_at", Type: field.TypeTime, Nullable: true},
		{Name: "revoked_reason", Type: field.TypeString, Nullable: true},
		{Name: "client_ip", Type: field.TypeString, Nullable: true},
		{Name: "user_agent", Type: field.TypeString, Nullable: true},
		{Name: "last_used_at", Type: field.TypeTime, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "app_id", Type: field.TypeUUID},
		{Name: "user_id", Type: field.TypeUUID, Nullable: true},
	}
	// SfOauthTokensTable holds the schema information for the "sf_oauth_tokens" table.
	SfOauthTokensTable = &schema.Table{
		Name:       "sf_oauth_tokens",
		Columns:    SfOauthTokensColumns,
		PrimaryKey: []*schema.Column{SfOauthTokensColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_oauth_tokens_sf_oauth_apps_tokens",
				Columns:    []*schema.Column{SfOauthTokensColumns[18]},
				RefColumns: []*schema.Column{SfOauthAppsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_oauth_tokens_sf_users_oauth_tokens",
				Columns:    []*schema.Column{SfOauthTokensColumns[19]},
				RefColumns: []*schema.Column{SfUsersColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "oauthtoken_access_token_signature",
				Unique:  true,
				Columns: []*schema.Column{SfOauthTokensColumns[2]},
			},
			{
				Name:    "oauthtoken_refresh_token_signature",
				Unique:  true,
				Columns: []*schema.Column{SfOauthTokensColumns[3]},
			},
			{
				Name:    "oauthtoken_app_id",
				Unique:  false,
				Columns: []*schema.Column{SfOauthTokensColumns[18]},
			},
			{
				Name:    "oauthtoken_user_id",
				Unique:  false,
				Columns: []*schema.Column{SfOauthTokensColumns[19]},
			},
			{
				Name:    "oauthtoken_family_id",
				Unique:  false,
				Columns: []*schema.Column{SfOauthTokensColumns[4]},
			},
			{
				Name:    "oauthtoken_revoked",
				Unique:  false,
				Columns: []*schema.Column{SfOauthTokensColumns[11]},
			},
			{
				Name:    "oauthtoken_access_expires_at",
				Unique:  false,
				Columns: []*schema.Column{SfOauthTokensColumns[9]},
			},
		},
	}
	// SfOrganizationsColumns holds the columns for the "sf_organizations" table.
	SfOrganizationsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "name", Type: field.TypeString},
		{Name: "slug", Type: field.TypeString, Unique: true},
		{Name: "org_type", Type: field.TypeEnum, Enums: []string{"personal", "team", "enterprise"}, Default: "team"},
		{Name: "logo_url", Type: field.TypeString, Nullable: true},
		{Name: "description", Type: field.TypeString, Nullable: true},
		{Name: "website_url", Type: field.TypeString, Nullable: true},
		{Name: "settings", Type: field.TypeJSON, Nullable: true},
		{Name: "plan", Type: field.TypeEnum, Enums: []string{"free", "starter", "pro", "enterprise"}, Default: "free"},
		{Name: "active", Type: field.TypeBool, Default: true},
		{Name: "owner_principal_id", Type: field.TypeUUID, Nullable: true},
	}
	// SfOrganizationsTable holds the schema information for the "sf_organizations" table.
	SfOrganizationsTable = &schema.Table{
		Name:       "sf_organizations",
		Columns:    SfOrganizationsColumns,
		PrimaryKey: []*schema.Column{SfOrganizationsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_organizations_sf_principals_owned_organizations",
				Columns:    []*schema.Column{SfOrganizationsColumns[12]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "organization_slug",
				Unique:  true,
				Columns: []*schema.Column{SfOrganizationsColumns[4]},
			},
			{
				Name:    "organization_active",
				Unique:  false,
				Columns: []*schema.Column{SfOrganizationsColumns[11]},
			},
			{
				Name:    "organization_org_type",
				Unique:  false,
				Columns: []*schema.Column{SfOrganizationsColumns[5]},
			},
			{
				Name:    "organization_owner_principal_id",
				Unique:  false,
				Columns: []*schema.Column{SfOrganizationsColumns[12]},
			},
			{
				Name:    "organization_org_type_active",
				Unique:  false,
				Columns: []*schema.Column{SfOrganizationsColumns[5], SfOrganizationsColumns[11]},
			},
		},
	}
	// SfPrincipalsColumns holds the columns for the "sf_principals" table.
	SfPrincipalsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "type", Type: field.TypeEnum, Enums: []string{"human", "application", "agent", "service"}},
		{Name: "identifier", Type: field.TypeString, Unique: true},
		{Name: "display_name", Type: field.TypeString},
		{Name: "active", Type: field.TypeBool, Default: true},
		{Name: "capabilities", Type: field.TypeJSON},
		{Name: "allowed_scopes", Type: field.TypeJSON},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "organization_id", Type: field.TypeUUID, Nullable: true},
	}
	// SfPrincipalsTable holds the schema information for the "sf_principals" table.
	SfPrincipalsTable = &schema.Table{
		Name:       "sf_principals",
		Columns:    SfPrincipalsColumns,
		PrimaryKey: []*schema.Column{SfPrincipalsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_principals_sf_organizations_principals",
				Columns:    []*schema.Column{SfPrincipalsColumns[10]},
				RefColumns: []*schema.Column{SfOrganizationsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "principal_identifier",
				Unique:  true,
				Columns: []*schema.Column{SfPrincipalsColumns[4]},
			},
			{
				Name:    "principal_type",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalsColumns[3]},
			},
			{
				Name:    "principal_organization_id",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalsColumns[10]},
			},
			{
				Name:    "principal_active",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalsColumns[6]},
			},
			{
				Name:    "principal_type_active",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalsColumns[3], SfPrincipalsColumns[6]},
			},
			{
				Name:    "principal_organization_id_type",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalsColumns[10], SfPrincipalsColumns[3]},
			},
		},
	}
	// SfPrincipalMembershipsColumns holds the columns for the "sf_principal_memberships" table.
	SfPrincipalMembershipsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "role", Type: field.TypeString},
		{Name: "permissions", Type: field.TypeJSON, Nullable: true},
		{Name: "active", Type: field.TypeBool, Default: true},
		{Name: "organization_id", Type: field.TypeUUID},
		{Name: "principal_id", Type: field.TypeUUID},
	}
	// SfPrincipalMembershipsTable holds the schema information for the "sf_principal_memberships" table.
	SfPrincipalMembershipsTable = &schema.Table{
		Name:       "sf_principal_memberships",
		Columns:    SfPrincipalMembershipsColumns,
		PrimaryKey: []*schema.Column{SfPrincipalMembershipsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_principal_memberships_sf_organizations_principal_memberships",
				Columns:    []*schema.Column{SfPrincipalMembershipsColumns[6]},
				RefColumns: []*schema.Column{SfOrganizationsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_principal_memberships_sf_principals_principal_memberships",
				Columns:    []*schema.Column{SfPrincipalMembershipsColumns[7]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "principalmembership_principal_id_organization_id",
				Unique:  true,
				Columns: []*schema.Column{SfPrincipalMembershipsColumns[7], SfPrincipalMembershipsColumns[6]},
			},
			{
				Name:    "principalmembership_principal_id",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalMembershipsColumns[7]},
			},
			{
				Name:    "principalmembership_organization_id",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalMembershipsColumns[6]},
			},
			{
				Name:    "principalmembership_role",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalMembershipsColumns[3]},
			},
			{
				Name:    "principalmembership_active",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalMembershipsColumns[5]},
			},
		},
	}
	// SfPrincipalTokensColumns holds the columns for the "sf_principal_tokens" table.
	SfPrincipalTokensColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "principal_type", Type: field.TypeEnum, Enums: []string{"human", "application", "agent", "service"}},
		{Name: "access_token_signature", Type: field.TypeString, Unique: true},
		{Name: "refresh_token_signature", Type: field.TypeString, Unique: true, Nullable: true},
		{Name: "family_id", Type: field.TypeUUID},
		{Name: "scopes", Type: field.TypeJSON},
		{Name: "audience", Type: field.TypeJSON},
		{Name: "capabilities", Type: field.TypeJSON},
		{Name: "delegation_chain", Type: field.TypeJSON},
		{Name: "dpop_jkt", Type: field.TypeString, Nullable: true},
		{Name: "session_id", Type: field.TypeString, Nullable: true},
		{Name: "request_data", Type: field.TypeString, Nullable: true, Size: 2147483647},
		{Name: "access_expires_at", Type: field.TypeTime},
		{Name: "refresh_expires_at", Type: field.TypeTime, Nullable: true},
		{Name: "revoked", Type: field.TypeBool, Default: false},
		{Name: "revoked_at", Type: field.TypeTime, Nullable: true},
		{Name: "revoked_reason", Type: field.TypeString, Nullable: true},
		{Name: "client_ip", Type: field.TypeString, Nullable: true},
		{Name: "user_agent", Type: field.TypeString, Nullable: true},
		{Name: "last_used_at", Type: field.TypeTime, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "issued_by_app_id", Type: field.TypeUUID, Nullable: true},
		{Name: "principal_id", Type: field.TypeUUID},
		{Name: "parent_token_id", Type: field.TypeUUID, Nullable: true},
	}
	// SfPrincipalTokensTable holds the schema information for the "sf_principal_tokens" table.
	SfPrincipalTokensTable = &schema.Table{
		Name:       "sf_principal_tokens",
		Columns:    SfPrincipalTokensColumns,
		PrimaryKey: []*schema.Column{SfPrincipalTokensColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_principal_tokens_sf_applications_issued_tokens",
				Columns:    []*schema.Column{SfPrincipalTokensColumns[21]},
				RefColumns: []*schema.Column{SfApplicationsColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "sf_principal_tokens_sf_principals_principal_tokens",
				Columns:    []*schema.Column{SfPrincipalTokensColumns[22]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_principal_tokens_sf_principal_tokens_child_tokens",
				Columns:    []*schema.Column{SfPrincipalTokensColumns[23]},
				RefColumns: []*schema.Column{SfPrincipalTokensColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "principaltoken_access_token_signature",
				Unique:  true,
				Columns: []*schema.Column{SfPrincipalTokensColumns[2]},
			},
			{
				Name:    "principaltoken_refresh_token_signature",
				Unique:  true,
				Columns: []*schema.Column{SfPrincipalTokensColumns[3]},
			},
			{
				Name:    "principaltoken_principal_id",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalTokensColumns[22]},
			},
			{
				Name:    "principaltoken_principal_type",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalTokensColumns[1]},
			},
			{
				Name:    "principaltoken_issued_by_app_id",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalTokensColumns[21]},
			},
			{
				Name:    "principaltoken_family_id",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalTokensColumns[4]},
			},
			{
				Name:    "principaltoken_parent_token_id",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalTokensColumns[23]},
			},
			{
				Name:    "principaltoken_revoked",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalTokensColumns[14]},
			},
			{
				Name:    "principaltoken_access_expires_at",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalTokensColumns[12]},
			},
			{
				Name:    "principaltoken_session_id",
				Unique:  false,
				Columns: []*schema.Column{SfPrincipalTokensColumns[10]},
			},
		},
	}
	// SfRefreshTokensColumns holds the columns for the "sf_refresh_tokens" table.
	SfRefreshTokensColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "token", Type: field.TypeString, Unique: true},
		{Name: "family", Type: field.TypeString},
		{Name: "expires_at", Type: field.TypeTime},
		{Name: "revoked", Type: field.TypeBool, Default: false},
		{Name: "user_agent", Type: field.TypeString, Nullable: true},
		{Name: "ip_address", Type: field.TypeString, Nullable: true},
		{Name: "user_id", Type: field.TypeUUID},
	}
	// SfRefreshTokensTable holds the schema information for the "sf_refresh_tokens" table.
	SfRefreshTokensTable = &schema.Table{
		Name:       "sf_refresh_tokens",
		Columns:    SfRefreshTokensColumns,
		PrimaryKey: []*schema.Column{SfRefreshTokensColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_refresh_tokens_sf_users_refresh_tokens",
				Columns:    []*schema.Column{SfRefreshTokensColumns[9]},
				RefColumns: []*schema.Column{SfUsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "refreshtoken_token",
				Unique:  true,
				Columns: []*schema.Column{SfRefreshTokensColumns[3]},
			},
			{
				Name:    "refreshtoken_user_id",
				Unique:  false,
				Columns: []*schema.Column{SfRefreshTokensColumns[9]},
			},
			{
				Name:    "refreshtoken_family",
				Unique:  false,
				Columns: []*schema.Column{SfRefreshTokensColumns[4]},
			},
			{
				Name:    "refreshtoken_expires_at",
				Unique:  false,
				Columns: []*schema.Column{SfRefreshTokensColumns[5]},
			},
			{
				Name:    "refreshtoken_revoked",
				Unique:  false,
				Columns: []*schema.Column{SfRefreshTokensColumns[6]},
			},
		},
	}
	// SfSeatAssignmentsColumns holds the columns for the "sf_seat_assignments" table.
	SfSeatAssignmentsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "assigned_at", Type: field.TypeTime},
		{Name: "license_id", Type: field.TypeUUID},
		{Name: "principal_id", Type: field.TypeUUID},
		{Name: "assigned_by", Type: field.TypeUUID},
	}
	// SfSeatAssignmentsTable holds the schema information for the "sf_seat_assignments" table.
	SfSeatAssignmentsTable = &schema.Table{
		Name:       "sf_seat_assignments",
		Columns:    SfSeatAssignmentsColumns,
		PrimaryKey: []*schema.Column{SfSeatAssignmentsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_seat_assignments_sf_licenses_seat_assignments",
				Columns:    []*schema.Column{SfSeatAssignmentsColumns[2]},
				RefColumns: []*schema.Column{SfLicensesColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_seat_assignments_sf_principals_seat_assignments",
				Columns:    []*schema.Column{SfSeatAssignmentsColumns[3]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_seat_assignments_sf_principals_assigned_seats",
				Columns:    []*schema.Column{SfSeatAssignmentsColumns[4]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "seatassignment_license_id",
				Unique:  false,
				Columns: []*schema.Column{SfSeatAssignmentsColumns[2]},
			},
			{
				Name:    "seatassignment_principal_id",
				Unique:  false,
				Columns: []*schema.Column{SfSeatAssignmentsColumns[3]},
			},
			{
				Name:    "seatassignment_assigned_by",
				Unique:  false,
				Columns: []*schema.Column{SfSeatAssignmentsColumns[4]},
			},
			{
				Name:    "seatassignment_license_id_principal_id",
				Unique:  true,
				Columns: []*schema.Column{SfSeatAssignmentsColumns[2], SfSeatAssignmentsColumns[3]},
			},
		},
	}
	// SfServiceAccountsColumns holds the columns for the "sf_service_accounts" table.
	SfServiceAccountsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "name", Type: field.TypeString, Size: 255},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
		{Name: "email", Type: field.TypeString, Unique: true},
		{Name: "allowed_scopes", Type: field.TypeJSON},
		{Name: "active", Type: field.TypeBool, Default: true},
		{Name: "last_used_at", Type: field.TypeTime, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "organization_id", Type: field.TypeUUID},
		{Name: "created_by", Type: field.TypeUUID},
	}
	// SfServiceAccountsTable holds the schema information for the "sf_service_accounts" table.
	SfServiceAccountsTable = &schema.Table{
		Name:       "sf_service_accounts",
		Columns:    SfServiceAccountsColumns,
		PrimaryKey: []*schema.Column{SfServiceAccountsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_service_accounts_sf_organizations_service_accounts",
				Columns:    []*schema.Column{SfServiceAccountsColumns[9]},
				RefColumns: []*schema.Column{SfOrganizationsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_service_accounts_sf_users_created_service_accounts",
				Columns:    []*schema.Column{SfServiceAccountsColumns[10]},
				RefColumns: []*schema.Column{SfUsersColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "serviceaccount_email",
				Unique:  true,
				Columns: []*schema.Column{SfServiceAccountsColumns[3]},
			},
			{
				Name:    "serviceaccount_organization_id",
				Unique:  false,
				Columns: []*schema.Column{SfServiceAccountsColumns[9]},
			},
			{
				Name:    "serviceaccount_active",
				Unique:  false,
				Columns: []*schema.Column{SfServiceAccountsColumns[5]},
			},
		},
	}
	// SfServiceAccountKeyPairsColumns holds the columns for the "sf_service_account_key_pairs" table.
	SfServiceAccountKeyPairsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "key_id", Type: field.TypeString},
		{Name: "key_type", Type: field.TypeEnum, Enums: []string{"rsa", "ec"}, Default: "rsa"},
		{Name: "algorithm", Type: field.TypeEnum, Enums: []string{"RS256", "RS384", "RS512", "ES256", "ES384", "ES512"}, Default: "RS256"},
		{Name: "public_key_pem", Type: field.TypeString, Size: 2147483647},
		{Name: "expires_at", Type: field.TypeTime, Nullable: true},
		{Name: "active", Type: field.TypeBool, Default: true},
		{Name: "last_used_at", Type: field.TypeTime, Nullable: true},
		{Name: "revoked", Type: field.TypeBool, Default: false},
		{Name: "revoked_at", Type: field.TypeTime, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "service_account_id", Type: field.TypeUUID},
	}
	// SfServiceAccountKeyPairsTable holds the schema information for the "sf_service_account_key_pairs" table.
	SfServiceAccountKeyPairsTable = &schema.Table{
		Name:       "sf_service_account_key_pairs",
		Columns:    SfServiceAccountKeyPairsColumns,
		PrimaryKey: []*schema.Column{SfServiceAccountKeyPairsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_service_account_key_pairs_sf_service_accounts_key_pairs",
				Columns:    []*schema.Column{SfServiceAccountKeyPairsColumns[11]},
				RefColumns: []*schema.Column{SfServiceAccountsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "serviceaccountkeypair_service_account_id_key_id",
				Unique:  true,
				Columns: []*schema.Column{SfServiceAccountKeyPairsColumns[11], SfServiceAccountKeyPairsColumns[1]},
			},
			{
				Name:    "serviceaccountkeypair_service_account_id",
				Unique:  false,
				Columns: []*schema.Column{SfServiceAccountKeyPairsColumns[11]},
			},
			{
				Name:    "serviceaccountkeypair_active",
				Unique:  false,
				Columns: []*schema.Column{SfServiceAccountKeyPairsColumns[6]},
			},
			{
				Name:    "serviceaccountkeypair_revoked",
				Unique:  false,
				Columns: []*schema.Column{SfServiceAccountKeyPairsColumns[8]},
			},
		},
	}
	// SfServicePrincipalsColumns holds the columns for the "sf_service_principals" table.
	SfServicePrincipalsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "service_type", Type: field.TypeString},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
		{Name: "last_used_at", Type: field.TypeTime, Nullable: true},
		{Name: "allowed_ips", Type: field.TypeJSON},
		{Name: "principal_id", Type: field.TypeUUID, Unique: true},
		{Name: "created_by", Type: field.TypeUUID, Nullable: true},
	}
	// SfServicePrincipalsTable holds the schema information for the "sf_service_principals" table.
	SfServicePrincipalsTable = &schema.Table{
		Name:       "sf_service_principals",
		Columns:    SfServicePrincipalsColumns,
		PrimaryKey: []*schema.Column{SfServicePrincipalsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_service_principals_sf_principals_service_principal",
				Columns:    []*schema.Column{SfServicePrincipalsColumns[7]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "sf_service_principals_sf_principals_creator",
				Columns:    []*schema.Column{SfServicePrincipalsColumns[8]},
				RefColumns: []*schema.Column{SfPrincipalsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "serviceprincipal_principal_id",
				Unique:  true,
				Columns: []*schema.Column{SfServicePrincipalsColumns[7]},
			},
			{
				Name:    "serviceprincipal_service_type",
				Unique:  false,
				Columns: []*schema.Column{SfServicePrincipalsColumns[3]},
			},
			{
				Name:    "serviceprincipal_created_by",
				Unique:  false,
				Columns: []*schema.Column{SfServicePrincipalsColumns[8]},
			},
		},
	}
	// SfSubscriptionsColumns holds the columns for the "sf_subscriptions" table.
	SfSubscriptionsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "plan_tier", Type: field.TypeString, Default: "free"},
		{Name: "status", Type: field.TypeEnum, Enums: []string{"active", "trialing", "past_due", "canceled", "unpaid"}, Default: "active"},
		{Name: "current_period_start", Type: field.TypeTime},
		{Name: "current_period_end", Type: field.TypeTime},
		{Name: "stripe_subscription_id", Type: field.TypeString, Unique: true, Nullable: true},
		{Name: "stripe_customer_id", Type: field.TypeString, Nullable: true},
		{Name: "cancel_at_period_end", Type: field.TypeBool, Default: false},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "organization_id", Type: field.TypeUUID, Unique: true},
	}
	// SfSubscriptionsTable holds the schema information for the "sf_subscriptions" table.
	SfSubscriptionsTable = &schema.Table{
		Name:       "sf_subscriptions",
		Columns:    SfSubscriptionsColumns,
		PrimaryKey: []*schema.Column{SfSubscriptionsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sf_subscriptions_sf_organizations_subscription",
				Columns:    []*schema.Column{SfSubscriptionsColumns[10]},
				RefColumns: []*schema.Column{SfOrganizationsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "subscription_organization_id",
				Unique:  true,
				Columns: []*schema.Column{SfSubscriptionsColumns[10]},
			},
			{
				Name:    "subscription_status",
				Unique:  false,
				Columns: []*schema.Column{SfSubscriptionsColumns[2]},
			},
			{
				Name:    "subscription_plan_tier",
				Unique:  false,
				Columns: []*schema.Column{SfSubscriptionsColumns[1]},
			},
			{
				Name:    "subscription_stripe_subscription_id",
				Unique:  false,
				Columns: []*schema.Column{SfSubscriptionsColumns[5]},
			},
			{
				Name:    "subscription_stripe_customer_id",
				Unique:  false,
				Columns: []*schema.Column{SfSubscriptionsColumns[6]},
			},
			{
				Name:    "subscription_current_period_end",
				Unique:  false,
				Columns: []*schema.Column{SfSubscriptionsColumns[4]},
			},
			{
				Name:    "subscription_status_current_period_end",
				Unique:  false,
				Columns: []*schema.Column{SfSubscriptionsColumns[2], SfSubscriptionsColumns[4]},
			},
		},
	}
	// SfUsersColumns holds the columns for the "sf_users" table.
	SfUsersColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "email", Type: field.TypeString, Unique: true},
		{Name: "name", Type: field.TypeString},
		{Name: "avatar_url", Type: field.TypeString, Nullable: true},
		{Name: "password_hash", Type: field.TypeString, Nullable: true},
		{Name: "is_platform_admin", Type: field.TypeBool, Default: false},
		{Name: "active", Type: field.TypeBool, Default: true},
		{Name: "last_login_at", Type: field.TypeTime, Nullable: true},
		{Name: "federation_id", Type: field.TypeUUID, Unique: true, Nullable: true},
	}
	// SfUsersTable holds the schema information for the "sf_users" table.
	SfUsersTable = &schema.Table{
		Name:       "sf_users",
		Columns:    SfUsersColumns,
		PrimaryKey: []*schema.Column{SfUsersColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "user_email",
				Unique:  true,
				Columns: []*schema.Column{SfUsersColumns[3]},
			},
			{
				Name:    "user_active",
				Unique:  false,
				Columns: []*schema.Column{SfUsersColumns[8]},
			},
			{
				Name:    "user_federation_id",
				Unique:  true,
				Columns: []*schema.Column{SfUsersColumns[10]},
			},
		},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		SfAPIKeysTable,
		SfAgentsTable,
		SfApplicationsTable,
		SfCredentialsTable,
		SfHumansTable,
		SfInvitesTable,
		SfLicensesTable,
		SfListingsTable,
		SfMembershipsTable,
		SfOauthAccountsTable,
		SfOauthAppsTable,
		SfOauthAppSecretsTable,
		SfOauthAuthCodesTable,
		SfOauthConsentsTable,
		SfOauthTokensTable,
		SfOrganizationsTable,
		SfPrincipalsTable,
		SfPrincipalMembershipsTable,
		SfPrincipalTokensTable,
		SfRefreshTokensTable,
		SfSeatAssignmentsTable,
		SfServiceAccountsTable,
		SfServiceAccountKeyPairsTable,
		SfServicePrincipalsTable,
		SfSubscriptionsTable,
		SfUsersTable,
	}
)

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