sqlmanager_postgres

package
v0.4.27 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPgTruncateCascadeStatement

func BuildPgTruncateCascadeStatement(
	schema string,
	table string,
) (string, error)

func BuildPgTruncateStatement

func BuildPgTruncateStatement(
	tables []string,
) string

func EscapePgColumn

func EscapePgColumn(col string) string

func EscapePgColumns

func EscapePgColumns(cols []string) []string

Types

type PostgresManager

type PostgresManager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(querier pg_queries.Querier, pool pg_queries.DBTX, closer func()) *PostgresManager

func (*PostgresManager) BatchExec

func (p *PostgresManager) BatchExec(ctx context.Context, batchSize int, statements []string, opts *sqlmanager_shared.BatchExecOpts) error

func (*PostgresManager) Close

func (p *PostgresManager) Close()

func (*PostgresManager) Exec

func (p *PostgresManager) Exec(ctx context.Context, statement string) error

func (*PostgresManager) GetCreateTableStatement

func (p *PostgresManager) GetCreateTableStatement(ctx context.Context, schema, table string) (string, error)

func (*PostgresManager) GetDatabaseSchema

func (p *PostgresManager) GetDatabaseSchema(ctx context.Context) ([]*sqlmanager_shared.DatabaseSchemaRow, error)

func (*PostgresManager) GetForeignKeyConstraints

func (p *PostgresManager) GetForeignKeyConstraints(ctx context.Context, schemas []string) ([]*sqlmanager_shared.ForeignKeyConstraintsRow, error)

func (*PostgresManager) GetForeignKeyConstraintsMap

func (p *PostgresManager) GetForeignKeyConstraintsMap(ctx context.Context, schemas []string) (map[string][]*sqlmanager_shared.ForeignConstraint, error)

Key is schema.table value is list of tables that key depends on

func (*PostgresManager) GetPrimaryKeyConstraints

func (p *PostgresManager) GetPrimaryKeyConstraints(ctx context.Context, schemas []string) ([]*sqlmanager_shared.PrimaryKey, error)

func (*PostgresManager) GetPrimaryKeyConstraintsMap

func (p *PostgresManager) GetPrimaryKeyConstraintsMap(ctx context.Context, schemas []string) (map[string][]string, error)

func (*PostgresManager) GetRolePermissionsMap

func (p *PostgresManager) GetRolePermissionsMap(ctx context.Context, role string) (map[string][]string, error)

func (*PostgresManager) GetSchemaColumnMap

func (p *PostgresManager) GetSchemaColumnMap(ctx context.Context) (map[string]map[string]*sqlmanager_shared.ColumnInfo, error)

returns: {public.users: { id: struct{}{}, created_at: struct{}{}}}

func (*PostgresManager) GetSchemaTableDataTypes

Returns ansilary dependencies like sequences, datatypes, functions, etc that are used by tables, but live at the schema level

func (*PostgresManager) GetSchemaTableTriggers

func (p *PostgresManager) GetSchemaTableTriggers(ctx context.Context, tables []*sqlmanager_shared.SchemaTable) ([]*sqlmanager_shared.TableTrigger, error)

func (*PostgresManager) GetTableConstraintsBySchema

func (p *PostgresManager) GetTableConstraintsBySchema(ctx context.Context, schemas []string) (*sqlmanager_shared.TableConstraints, error)

func (*PostgresManager) GetTableInitStatements

func (*PostgresManager) GetTableRowCount

func (p *PostgresManager) GetTableRowCount(
	ctx context.Context,
	schema, table string,
	whereClause *string,
) (int64, error)

func (*PostgresManager) GetUniqueConstraintsMap

func (p *PostgresManager) GetUniqueConstraintsMap(ctx context.Context, schemas []string) (map[string][][]string, error)

Jump to

Keyboard shortcuts

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