Documentation
¶
Index ¶
- func MaskPassword(connStr string) string
- type DatabaseInfo
- type Inspector
- func (i *Inspector) CheckConnection(ctx context.Context) error
- func (i *Inspector) CheckPermissions(ctx context.Context, name string) error
- func (i *Inspector) DatabaseExists(ctx context.Context, name string) (bool, error)
- func (i *Inspector) GetDatabaseURL(name string) string
- func (i *Inspector) InspectDatabase(ctx context.Context, name string) (*DatabaseInfo, error)
- func (i *Inspector) ListDatabases(ctx context.Context) ([]DatabaseInfo, error)
- type MigrationChecker
- func (m *MigrationChecker) CanApplyMigrations(state *MigrationState, dbHasTables bool) (bool, string)
- func (m *MigrationChecker) CheckDestructive(sql string) bool
- func (m *MigrationChecker) CheckState(ctx context.Context, dbName string) (*MigrationState, error)
- func (m *MigrationChecker) LoadMigrations() ([]MigrationFile, error)
- type MigrationFile
- type MigrationState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaskPassword ¶
MaskPassword masks the password in a connection string for display.
Types ¶
type DatabaseInfo ¶
type DatabaseInfo struct {
Name string
Owner string
Encoding string
Collation string
CType string
IsTemplate bool
Size string
HasTables bool
TableCount int
HasMigrations bool
MigrationVersion *int
IsDirty bool
}
DatabaseInfo represents information about a PostgreSQL database.
type Inspector ¶
type Inspector struct {
// contains filtered or unexported fields
}
Inspector provides methods to inspect PostgreSQL databases.
func NewInspector ¶
NewInspector creates a new database inspector.
func (*Inspector) CheckConnection ¶
CheckConnection tests if a connection can be established.
func (*Inspector) CheckPermissions ¶
CheckPermissions checks if the user has necessary permissions.
func (*Inspector) DatabaseExists ¶
DatabaseExists checks if a database exists.
func (*Inspector) GetDatabaseURL ¶
GetDatabaseURL returns a connection string for a specific database.
func (*Inspector) InspectDatabase ¶
InspectDatabase performs a detailed inspection of a specific database.
func (*Inspector) ListDatabases ¶
func (i *Inspector) ListDatabases(ctx context.Context) ([]DatabaseInfo, error)
ListDatabases returns all databases accessible with the connection string.
type MigrationChecker ¶
type MigrationChecker struct {
// contains filtered or unexported fields
}
MigrationChecker checks migration state against database.
func NewMigrationChecker ¶
func NewMigrationChecker(inspector *Inspector, migrationsDir string) *MigrationChecker
NewMigrationChecker creates a new migration checker.
func (*MigrationChecker) CanApplyMigrations ¶
func (m *MigrationChecker) CanApplyMigrations(state *MigrationState, dbHasTables bool) (bool, string)
CanApplyMigrations returns whether migrations can be safely applied.
func (*MigrationChecker) CheckDestructive ¶
func (m *MigrationChecker) CheckDestructive(sql string) bool
CheckDestructive checks if a migration contains potentially destructive operations.
func (*MigrationChecker) CheckState ¶
func (m *MigrationChecker) CheckState(ctx context.Context, dbName string) (*MigrationState, error)
CheckState checks the migration state against the database.
func (*MigrationChecker) LoadMigrations ¶
func (m *MigrationChecker) LoadMigrations() ([]MigrationFile, error)
LoadMigrations loads all migration files from the migrations directory.
type MigrationFile ¶
MigrationFile represents a migration file.
type MigrationState ¶
type MigrationState struct {
CurrentVersion *int
IsDirty bool
Available []MigrationFile
Applied []int
Pending []MigrationFile
HasDestructive bool
}
MigrationState represents the state of migrations.