tables

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 17 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: func(cfg *raiden.Config, param objects.Table) (response objects.Table, err error) {
		if cfg.Mode == raiden.SvcMode {
			return pgmeta.CreateTable(cfg, param)
		}
		return supabase.CreateTable(cfg, param)
	},
	UpdateFunc: func(cfg *raiden.Config, param objects.Table, items objects.UpdateTableParam) (err error) {
		if cfg.Mode == raiden.SvcMode {
			return pgmeta.UpdateTable(cfg, param, items)
		}
		return supabase.UpdateTable(cfg, param, items)
	},
	DeleteFunc: func(cfg *raiden.Config, param objects.Table) (err error) {
		if cfg.Mode == raiden.SvcMode {
			return pgmeta.DeleteTable(cfg, param, true)
		}
		return supabase.DeleteTable(cfg, param, true)
	},
}
View Source
var Logger hclog.Logger = logger.HcLog().Named("resource.tables")

Functions

func AttachIndexAndAction added in v1.0.0

func AttachIndexAndAction(allTable []objects.Table, allIndex []objects.Index, allAction []objects.TablesRelationshipAction) []objects.Table

--- attach index and action to relation

func BuildGenerateModelInputs

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

func Compare

func Compare(mode CompareMode, 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(mode CompareMode, source, target objects.Table) (diffResult CompareDiffResult)

func CompareList

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

type CompareMode added in v1.0.0

type CompareMode string
const (
	CompareModeImport CompareMode = "import"
	CompareModeApply  CompareMode = "apply"
)

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, allowedTable []string) (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