schema

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MigrationExample = `` /* 523-byte string literal not displayed */

Example migration SQL for adding metadata column to existing tables

View Source
const PostgreSQLExample = `` /* 1049-byte string literal not displayed */

PostgreSQL DDL example with JSONB support

View Source
const SQLiteExample = `` /* 1053-byte string literal not displayed */

SQLite DDL example with JSON support

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseType

type DatabaseType string

DatabaseType represents supported database types

const (
	PostgreSQL DatabaseType = "postgresql"
	SQLite     DatabaseType = "sqlite"
	MySQL      DatabaseType = "mysql"
)

func ParseDatabaseType

func ParseDatabaseType(s string) DatabaseType

ParseDatabaseType parses a string into a DatabaseType

func (DatabaseType) GetBlobColumnType

func (dt DatabaseType) GetBlobColumnType() string

GetBlobColumnType returns the appropriate BLOB column type for each database

func (DatabaseType) GetIntegerColumnType

func (dt DatabaseType) GetIntegerColumnType() string

GetIntegerColumnType returns the appropriate integer column type for each database

func (DatabaseType) GetJSONColumnType

func (dt DatabaseType) GetJSONColumnType() string

GetJSONColumnType returns the appropriate JSON column type for each database

func (DatabaseType) GetJSONExtractFunction

func (dt DatabaseType) GetJSONExtractFunction(column, path string) string

GetJSONExtractFunction returns the JSON extraction function for each database

func (DatabaseType) GetJSONValidationConstraint

func (dt DatabaseType) GetJSONValidationConstraint(columnName string) string

GetJSONValidationConstraint returns the JSON validation constraint for databases that need it

func (DatabaseType) GetMetadataIndexSQL

func (dt DatabaseType) GetMetadataIndexSQL(tableName, indexName, path string) string

GetMetadataIndexSQL returns the SQL for creating metadata indexes

func (DatabaseType) GetTimestampColumnType

func (dt DatabaseType) GetTimestampColumnType() string

GetTimestampColumnType returns the appropriate timestamp column type for each database

func (DatabaseType) IsValid

func (dt DatabaseType) IsValid() bool

IsValid checks if the database type is supported

func (DatabaseType) RequiresJSONValidation

func (dt DatabaseType) RequiresJSONValidation() bool

RequiresJSONValidation returns true if the database requires JSON validation constraints

func (DatabaseType) String

func (dt DatabaseType) String() string

String returns the string representation of the database type

func (DatabaseType) SupportsJSONIndexing

func (dt DatabaseType) SupportsJSONIndexing() bool

SupportsJSONIndexing returns true if the database supports efficient JSON indexing

type MetadataColumn

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

MetadataColumn provides cross-database JSON column support It implements sql.Scanner and driver.Valuer for seamless database integration

func NewMetadataColumn

func NewMetadataColumn() *MetadataColumn

NewMetadataColumn creates a new MetadataColumn instance

func (*MetadataColumn) Clear

func (mc *MetadataColumn) Clear()

Clear removes all data from the metadata

func (*MetadataColumn) Delete

func (mc *MetadataColumn) Delete(key string)

Delete removes a key from the metadata

func (*MetadataColumn) FromJSON

func (mc *MetadataColumn) FromJSON(data []byte) error

FromJSON populates the metadata from JSON bytes

func (*MetadataColumn) Get

func (mc *MetadataColumn) Get(key string) (interface{}, bool)

Get retrieves a value by key from the metadata

func (*MetadataColumn) GetInt

func (mc *MetadataColumn) GetInt(key string) (int, bool)

GetInt retrieves an int value by key

func (*MetadataColumn) GetString

func (mc *MetadataColumn) GetString(key string) (string, bool)

GetString retrieves a string value by key

func (*MetadataColumn) IsEmpty

func (mc *MetadataColumn) IsEmpty() bool

IsEmpty returns true if the metadata contains no data

func (*MetadataColumn) Keys

func (mc *MetadataColumn) Keys() []string

Keys returns all keys in the metadata

func (*MetadataColumn) Scan

func (mc *MetadataColumn) Scan(value interface{}) error

Scan implements sql.Scanner for database/sql This handles reading JSON data from both PostgreSQL JSONB and SQLite TEXT columns

func (*MetadataColumn) Set

func (mc *MetadataColumn) Set(key string, value interface{})

Set stores a key-value pair in the metadata

func (*MetadataColumn) ToJSON

func (mc *MetadataColumn) ToJSON() ([]byte, error)

ToJSON returns the JSON representation of the metadata

func (MetadataColumn) Value

func (mc MetadataColumn) Value() (driver.Value, error)

Value implements driver.Valuer for database/sql This returns JSON bytes for storage in the database

Jump to

Keyboard shortcuts

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