tables

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DiffChangeTemplate = `` /* 330-byte string literal not displayed */
View Source
const DiffChangeUpdateTemplate = `` /* 441-byte string literal not displayed */
View Source
const DiffTemplate = ` 
{{- .Columns}}
{{- .Metadata}}
{{- .Acl}}
{{- .Relations}}
  `

----- generate message section ------

Variables

View Source
var ActionFunc = MigrateActionFunc{
	CreateFunc: supabase.CreateTable, UpdateFunc: supabase.UpdateTable,
	DeleteFunc: func(cfg *raiden.Config, param objects.Table) (err error) {
		return supabase.DeleteTable(cfg, param, true)
	},
}
View Source
var Logger hclog.Logger = logger.HcLog().Named("resource.tables")

Functions

func BuildGenerateModelInputs

func BuildGenerateModelInputs(tables []objects.Table, policies objects.Policies, mapModelValidationTags map[string]state.ModelValidationTag) []*generator.GenerateModelInput

func Compare

func Compare(source []objects.Table, target []objects.Table) error

func GenerateDiffChangeMessage

func GenerateDiffChangeMessage(newTable []string, updateTable []string, deleteTable []string) (string, error)

func GenerateDiffChangeUpdateMessage

func GenerateDiffChangeUpdateMessage(name string, item MigrateItem) (string, error)

func GenerateDiffMessage

func GenerateDiffMessage(diffData CompareDiffResult, sRelation MapRelations, tRelation MapRelations) (string, error)

func GetDiffChangeMessage

func GetDiffChangeMessage(items []MigrateItem) string

func GetNewCountData

func GetNewCountData(supabaseData []objects.Table, localData state.ExtractTableResult) int

func Migrate

func Migrate(config *raiden.Config, tables []MigrateItem, stateChan chan any, actions MigrateActionFunc) []error

func PrintDiff

func PrintDiff(diffData CompareDiffResult, sRelation MapRelations, tRelation MapRelations)

func PrintDiffResult

func PrintDiffResult(diffResult []CompareDiffResult, sRelation MapRelations, tRelation MapRelations) error

Types

type CompareDiffResult

type CompareDiffResult struct {
	Name           string
	SourceResource objects.Table
	TargetResource objects.Table
	DiffItems      objects.UpdateTableParam
	IsConflict     bool
}

func CompareItem

func CompareItem(source, target objects.Table) (diffResult CompareDiffResult)

func CompareList

func CompareList(sourceTable, targetTable []objects.Table) (diffResult []CompareDiffResult, err error)

type ManyToManyTable

type ManyToManyTable struct {
	Table      string
	Schema     string
	PivotTable string
	PrimaryKey string
	ForeignKey string
}

---- build table relation for generated -----

type MapRelations

type MapRelations map[string][]*state.Relation

---- build table relation for generated -----

type MapTable

type MapTable map[string]*objects.Table

----- Convert array of table to map table -----

type MigrateItem

func BuildMigrateData

func BuildMigrateData(extractedLocalData state.ExtractTableResult, supabaseData []objects.Table) (migrateData []MigrateItem, err error)

func BuildMigrateItem

func BuildMigrateItem(supabaseData, localData []objects.Table) (migratedData []MigrateItem, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL