Documentation ¶
Index ¶
- func Apply(flags *Flags, config *raiden.Config) error
- func FindResource[T any](data []T, input generator.GenerateInput, ...) (item T, found bool)
- func Import(flags *Flags, config *raiden.Config) error
- func ImportDecorateFunc[T any](data []T, findFunc func(T, generator.GenerateInput) bool, stateChan chan any) generator.GenerateFn
- func ListenApplyResource(projectPath string, resourceState *ResourceState, stateChan chan any) (done chan error)
- func ListenImportResource(resourceState *ResourceState, stateChan chan any) (done chan error)
- func MigrateResource(config *raiden.Config, importState *ResourceState, projectPath string, ...) (errors []error)
- func PreRun(projectPath string) error
- func PrintDiff(resource string, supabaseResource, appResource interface{}, prefix string)
- func PrintDiffDetail(resource, prefix string, attribute string, spValue, appValue string)
- func RegisterModels(list ...any)
- func RegisterRole(list ...raiden.Role)
- func RegisterRpc(list ...raiden.Rpc)
- func RegisterStorages(list ...raiden.Bucket)
- type CompareDiffResult
- func ComparePolicies(sourcePolicies, targetPolicies []objects.Policy) (diffResult []CompareDiffResult[objects.Policy, objects.UpdatePolicyParam])
- func CompareRoleImportMode(source, target objects.Role) (diffResult CompareDiffResult[objects.Role, objects.UpdateRoleParam], err error)
- func CompareRoles(sourceRole, targetRole []objects.Role, mode CompareMode) (diffResult []CompareDiffResult[objects.Role, objects.UpdateRoleParam], ...)
- func CompareRpcFunctions(sourceFn []objects.Function, targetFn []objects.Function) (diffResult []CompareDiffResult[objects.Function, any], err error)
- func CompareStorage(sourceStorage, targetStorage []objects.Bucket) (diffResult []CompareDiffResult[objects.Bucket, objects.UpdateBucketParam], ...)
- func CompareTables(sourceTable, targetTable []objects.Table, mode CompareMode) (diffResult []CompareDiffResult[objects.Table, objects.UpdateTableParam], ...)
- type CompareMode
- type Flags
- type ManyToManyTable
- type MapRelations
- type MapTable
- type MigrateActionFunc
- type MigrateCreateFunc
- type MigrateData
- type MigrateDeleteFunc
- type MigrateFunc
- type MigrateFuncParam
- type MigrateItem
- type MigrateTableNode
- type MigrateType
- type MigrateUpdateFunc
- type Resource
- type ResourceState
- func (s *ResourceState) AddRole(role state.RoleState)
- func (s *ResourceState) AddRpc(rpc state.RpcState)
- func (s *ResourceState) AddStorage(storage state.StorageState)
- func (s *ResourceState) AddTable(table state.TableState)
- func (s *ResourceState) DeleteRole(roleId int)
- func (s *ResourceState) DeleteRpc(rpcId int)
- func (s *ResourceState) DeleteStorage(storageId string)
- func (s *ResourceState) DeleteTable(tableId int)
- func (s *ResourceState) FindRole(roleId int) (index int, roleState state.RoleState, found bool)
- func (s *ResourceState) FindRpc(rpcId int) (index int, rpcState state.RpcState, found bool)
- func (s *ResourceState) FindStorage(storageId string) (index int, storageState state.StorageState, found bool)
- func (s *ResourceState) FindTable(tableId int) (index int, tableState state.TableState, found bool)
- func (s *ResourceState) Persist() error
- func (s *ResourceState) UpdateRole(index int, state state.RoleState)
- func (s *ResourceState) UpdateRpc(index int, state state.RpcState)
- func (s *ResourceState) UpdateStorage(index int, state state.StorageState)
- func (s *ResourceState) UpdateTable(index int, state state.TableState)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Migrate resource :
[ ] migrate table
[x] create table name, schema and columns [x] create table rls enable [x] create table rls force [x] create table with primary key [x] create table with relation (ordered table by relation) [x] create table with acl (rls) [x] delete table (cascade) [x] update table name, schema [x] update table rls enable [x] update table rls force [x] update table with relation - create, update and delete (ordered table by relation) [x] create table with acl (rls), for now all rls outside manage from raiden will be delete [x] update table column add new column [x] update table column delete column [x] update table column set default schema [x] update table column set set data type [x] update table column set unique column [x] update table column set nullable
[ ] migrate role
[x] create new role [x] create role with connection limit [x] create role with inherit [ ] create role with is replicate - unsupported now because need superuser role [ ] create role with is super user - unsupported now because need superuser role [x] create role with can bypass rls, can create db, can create role, can login [x] create role with valid until [x] delete role [ ] update name [x] update connection limit [x] update inherit [ ] update is replicate [ ] update is super user [x] update can bypass rls [x] update can create db [x] update can create role [x] update can login [x] update valid until
[x] migrate function (Rpc)
[x] migrate storage
[ ] create new storage [ ] update storage [ ] delete storage [ ] add storage acl [ ] update storage acl
func FindResource ¶
func FindResource[T any](data []T, input generator.GenerateInput, findFunc func(item T, inputData generator.GenerateInput) bool) (item T, found bool)
func Import ¶
List of import resource [x] import table, relation, column specification and acl [x] import role [x] import function [x] import storage
func ImportDecorateFunc ¶
func ImportDecorateFunc[T any](data []T, findFunc func(T, generator.GenerateInput) bool, stateChan chan any) generator.GenerateFn
func ListenApplyResource ¶
func ListenApplyResource(projectPath string, resourceState *ResourceState, stateChan chan any) (done chan error)
func ListenImportResource ¶
func ListenImportResource(resourceState *ResourceState, stateChan chan any) (done chan error)
func MigrateResource ¶
func MigrateResource(config *raiden.Config, importState *ResourceState, projectPath string, resource *MigrateData) (errors []error)
func PrintDiffDetail ¶
func RegisterModels ¶
func RegisterModels(list ...any)
func RegisterRole ¶
func RegisterRpc ¶
func RegisterStorages ¶
Types ¶
type CompareDiffResult ¶
type CompareDiffResult[T any, D any] struct { Name string SourceResource T TargetResource T DiffItems D IsConflict bool }
func ComparePolicies ¶
func ComparePolicies(sourcePolicies, targetPolicies []objects.Policy) (diffResult []CompareDiffResult[objects.Policy, objects.UpdatePolicyParam])
func CompareRoleImportMode ¶
func CompareRoleImportMode(source, target objects.Role) (diffResult CompareDiffResult[objects.Role, objects.UpdateRoleParam], err error)
func CompareRoles ¶
func CompareRoles(sourceRole, targetRole []objects.Role, mode CompareMode) (diffResult []CompareDiffResult[objects.Role, objects.UpdateRoleParam], err error)
func CompareRpcFunctions ¶
func CompareStorage ¶
func CompareStorage(sourceStorage, targetStorage []objects.Bucket) (diffResult []CompareDiffResult[objects.Bucket, objects.UpdateBucketParam], err error)
func CompareTables ¶
func CompareTables(sourceTable, targetTable []objects.Table, mode CompareMode) (diffResult []CompareDiffResult[objects.Table, objects.UpdateTableParam], err error)
CompareTables is function for find different table configuration between supabase and app
for CompareModeImport source table is supabase table and target table is app table for CompareModeApply source table is app table and target table is supabase table
type CompareMode ¶
type CompareMode string
const ( CompareModeImport CompareMode = "import" CompareModeApply CompareMode = "apply" )
type Flags ¶
type Flags struct { ProjectPath string RpcOnly bool RolesOnly bool ModelsOnly bool StorageOnly bool AllowedSchema string Verbose bool Generate generate.Flags }
Flags is struct to binding options when import and apply is run binart
type ManyToManyTable ¶
type ManyToManyTable struct { Table string Schema string PivotTable string PrimaryKey string ForeignKey string }
---- build table relation for generated -----
type MapRelations ¶
---- build table relation for generated -----
type MigrateActionFunc ¶
type MigrateActionFunc[T, D any] struct { CreateFunc MigrateCreateFunc[T] UpdateFunc MigrateUpdateFunc[T, D] DeleteFunc MigrateDeleteFunc[T] }
type MigrateCreateFunc ¶
type MigrateData ¶
type MigrateData struct { Tables []MigrateItem[objects.Table, objects.UpdateTableParam] Roles []MigrateItem[objects.Role, objects.UpdateRoleParam] Rpc []MigrateItem[objects.Function, any] Policies []MigrateItem[objects.Policy, objects.UpdatePolicyParam] Storages []MigrateItem[objects.Bucket, objects.UpdateBucketParam] }
type MigrateDeleteFunc ¶
type MigrateFunc ¶
type MigrateFunc[T, D any] func(param MigrateFuncParam[T, D]) error
type MigrateFuncParam ¶
type MigrateFuncParam[T, D any] struct { Config *raiden.Config StateChan chan any Data MigrateItem[T, D] ActionFuncs MigrateActionFunc[T, D] }
type MigrateItem ¶
type MigrateItem[T, D any] struct { Type MigrateType NewData T OldData T MigrationItems D }
type MigrateTableNode ¶
type MigrateTableNode struct { Level int MigratedItems []MigrateItem[objects.Table, objects.UpdateTableParam] Child *MigrateTableNode }
type MigrateType ¶
type MigrateType string
const ( MigrateTypeIgnore MigrateType = "ignore" MigrateTypeCreate MigrateType = "create" MigrateTypeUpdate MigrateType = "update" MigrateTypeDelete MigrateType = "delete" )
type MigrateUpdateFunc ¶
type Resource ¶
type ResourceState ¶
func (*ResourceState) AddRole ¶
func (s *ResourceState) AddRole(role state.RoleState)
func (*ResourceState) AddRpc ¶
func (s *ResourceState) AddRpc(rpc state.RpcState)
func (*ResourceState) AddStorage ¶
func (s *ResourceState) AddStorage(storage state.StorageState)
func (*ResourceState) AddTable ¶
func (s *ResourceState) AddTable(table state.TableState)
func (*ResourceState) DeleteRole ¶
func (s *ResourceState) DeleteRole(roleId int)
func (*ResourceState) DeleteRpc ¶
func (s *ResourceState) DeleteRpc(rpcId int)
func (*ResourceState) DeleteStorage ¶
func (s *ResourceState) DeleteStorage(storageId string)
func (*ResourceState) DeleteTable ¶
func (s *ResourceState) DeleteTable(tableId int)
func (*ResourceState) FindStorage ¶
func (s *ResourceState) FindStorage(storageId string) (index int, storageState state.StorageState, found bool)
func (*ResourceState) FindTable ¶
func (s *ResourceState) FindTable(tableId int) (index int, tableState state.TableState, found bool)
func (*ResourceState) Persist ¶
func (s *ResourceState) Persist() error
func (*ResourceState) UpdateRole ¶
func (s *ResourceState) UpdateRole(index int, state state.RoleState)
func (*ResourceState) UpdateRpc ¶
func (s *ResourceState) UpdateRpc(index int, state state.RpcState)
func (*ResourceState) UpdateStorage ¶
func (s *ResourceState) UpdateStorage(index int, state state.StorageState)
func (*ResourceState) UpdateTable ¶
func (s *ResourceState) UpdateTable(index int, state state.TableState)