dbz

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustApplyMigrations

func MustApplyMigrations(cfg *MigrationsConfig)

MustApplyMigrations applies all migrations.

func MustRollBackMigrations

func MustRollBackMigrations(cfg *MigrationsConfig, targetVersion int32)

MustRollBackMigrations rolls migrations back.

func MustShowMigrations

func MustShowMigrations(cfg *MigrationsConfig)

MustShowMigrations shows migrations.

Types

type MigrationsConfig

type MigrationsConfig struct {
	PostgresURL string
	TableName   string
	FS          embed.FS
}

MigrationsConfig describes the configuration for migrations.

type SQLCConfig added in v0.7.0

type SQLCConfig struct {
	Version string              `json:"version,omitempty"`
	Plugins []*SQLCConfigPlugin `json:"plugins,omitempty"`
	SQL     []*SQLCConfigSQL    `json:"sql,omitempty"`
}

SQLCConfig describes the SQLC configuration.

type SQLCConfigPlugin added in v0.7.0

type SQLCConfigPlugin struct {
	Name string                `json:"name,omitempty"`
	WASM *SQLCConfigPluginWASM `json:"wasm,omitempty"`
}

SQLCConfigPlugin describes part of the SQLC configuration.

type SQLCConfigPluginWASM added in v0.7.0

type SQLCConfigPluginWASM struct {
	URL    string `json:"url,omitempty"`
	SHA256 string `json:"sha256,omitempty"`
}

SQLCConfigPluginWASM describes part of the SQLC configuration.

type SQLCConfigSQL added in v0.7.0

type SQLCConfigSQL struct {
	Engine   string                  `json:"engine,omitempty"`
	Schema   string                  `json:"schema,omitempty"`
	Queries  string                  `json:"queries,omitempty"`
	Database *SQLCConfigSQLDatabase  `json:"database,omitempty"`
	Codegen  []*SQLCConfigSQLCodegen `json:"codegen,omitempty"`
	Rules    []string                `json:"rules"`
}

SQLCConfigSQL describes part of the SQLC configuration.

type SQLCConfigSQLCodegen added in v0.7.0

type SQLCConfigSQLCodegen struct {
	Plugin  string                       `json:"plugin,omitempty"`
	Out     string                       `json:"out,omitempty"`
	Options *SQLCConfigSQLCodegenOptions `json:"options,omitempty"`
}

SQLCConfigSQLCodegen describes part of the SQLC configuration.

type SQLCConfigSQLCodegenOptions added in v0.7.0

type SQLCConfigSQLCodegenOptions struct {
	BuildTags                   string                                 `json:"build_tags,omitempty"`
	EmitAllEnumValues           bool                                   `json:"emit_all_enum_values"`
	EmitDbTags                  bool                                   `json:"emit_db_tags"`
	EmitEmptySlices             bool                                   `json:"emit_empty_slices"`
	EmitEnumValidMethod         bool                                   `json:"emit_enum_valid_method"`
	EmitExactTableNames         bool                                   `json:"emit_exact_table_names"`
	EmitExportedQueries         bool                                   `json:"emit_exported_queries"`
	EmitInterface               bool                                   `json:"emit_interface"`
	EmitJSONTags                bool                                   `json:"emit_json_tags"`
	EmitMethodsWithDBArgument   bool                                   `json:"emit_methods_with_db_argument"`
	EmitParamsStructPointers    bool                                   `json:"emit_params_struct_pointers"`
	EmitPointersForNullTypes    bool                                   `json:"emit_pointers_for_null_types"`
	EmitPreparedQueries         bool                                   `json:"emit_prepared_queries"`
	EmitResultStructPointers    bool                                   `json:"emit_result_struct_pointers"`
	EmitSQLAsComment            bool                                   `json:"emit_sql_as_comment"`
	InflectionExcludeTableNames []string                               `json:"inflection_exclude_table_names,omitempty"`
	JSONTagsCaseStyle           string                                 `json:"json_tags_case_style,omitempty"`
	JSONTagsIDUppercase         bool                                   `json:"json_tags_id_uppercase"`
	OmitSQLCVersion             bool                                   `json:"omit_sqlc_version"`
	OmitUnusedStructs           bool                                   `json:"omit_unused_structs"`
	OutputBatchFileName         string                                 `json:"output_batch_file_name,omitempty"`
	OutputCopyFromFileName      string                                 `json:"output_copyfrom_file_name,omitempty"`
	OutputDBFileName            string                                 `json:"output_db_file_name,omitempty"`
	OutputFilesSuffix           string                                 `json:"output_files_suffix,omitempty"`
	OutputModelsFileName        string                                 `json:"output_models_file_name,omitempty"`
	OutputQuerierFileName       string                                 `json:"output_querier_file_name,omitempty"`
	Overrides                   []*SQLCConfigSQLCodegenOptionsOverride `json:"overrides,omitempty"`
	Package                     string                                 `json:"package,omitempty"`
	QueryParameterLimit         int32                                  `json:"query_parameter_limit"`
	Rename                      map[string]string                      `json:"rename,omitempty"`
	SQLDriver                   string                                 `json:"sql_driver,omitempty"`
	SQLPackage                  string                                 `json:"sql_package,omitempty"`
}

SQLCConfigSQLCodegenOptions describes part of the SQLC configuration.

type SQLCConfigSQLCodegenOptionsOverride added in v0.7.0

type SQLCConfigSQLCodegenOptionsOverride struct {
	Column      string                                     `json:"column,omitempty"`
	DBType      string                                     `json:"db_type,omitempty"`
	Nullable    bool                                       `json:"nullable"`
	Unsigned    bool                                       `json:"unsigned"`
	GoType      *SQLCConfigSQLCodegenOptionsOverrideGoType `json:"go_type,omitempty"`
	GoStructTag string                                     `json:"go_struct_tag,omitempty"`
}

SQLCConfigSQLCodegenOptionsOverride describes part of the SQLC configuration.

type SQLCConfigSQLCodegenOptionsOverrideGoType added in v0.7.0

type SQLCConfigSQLCodegenOptionsOverrideGoType struct {
	Import  string `json:"import,omitempty"`
	Package string `json:"package,omitempty"`
	Type    string `json:"type,omitempty"`
	Pointer bool   `json:"pointer"`
	Slice   bool   `json:"slice"`
}

SQLCConfigSQLCodegenOptionsOverrideGoType describes part of the SQLC configuration.

type SQLCConfigSQLDatabase added in v0.7.0

type SQLCConfigSQLDatabase struct {
	Managed bool   `json:"managed"`
	URI     string `json:"uri,omitempty"`
}

SQLCConfigSQLDatabase describes part of the SQLC configuration.

type SQLCGenerator added in v0.7.0

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

SQLCGenerator generates database bindings with SQLC.

func MustNewSQLCGenerator added in v0.7.0

func MustNewSQLCGenerator(params *SQLCGeneratorParams) *SQLCGenerator

MustNewSQLCGenerator initializes a new SQLCGenerator.

func (*SQLCGenerator) AddOverride added in v0.7.0

func (c *SQLCGenerator) AddOverride(overrides ...*SQLCConfigSQLCodegenOptionsOverride) *SQLCGenerator

AddOverride adds an override to the config.

func (*SQLCGenerator) MergeRenames added in v0.7.0

func (c *SQLCGenerator) MergeRenames(m map[string]string) *SQLCGenerator

MergeRenames merges the given rename rules.

func (*SQLCGenerator) MustGenerate added in v0.7.0

func (c *SQLCGenerator) MustGenerate()

MustGenerate generates the SQLC bindings.

func (*SQLCGenerator) MustOutput added in v0.7.0

func (c *SQLCGenerator) MustOutput()

MustOutput the config to disk.

func (*SQLCGenerator) SetRename added in v0.7.0

func (c *SQLCGenerator) SetRename(k, v string) *SQLCGenerator

SetRename sets a rename rule.

type SQLCGeneratorParams added in v0.7.0

type SQLCGeneratorParams struct {
	BuildDirPath   string `validate:"required"`
	SchemaDirPath  string `validate:"required"`
	QueriesDirPath string `validate:"required"`
	PostgresURL    string `validate:"required"`
	OutDirPath     string `validate:"required"`
	OutPackageName string `validate:"required"`
}

SQLCGeneratorParams describes parameters.

func (*SQLCGeneratorParams) GetConfigFilePath added in v0.7.0

func (p *SQLCGeneratorParams) GetConfigFilePath() string

GetConfigFilePath returns the config file path.

func (*SQLCGeneratorParams) GetPluginFilePath added in v0.7.0

func (p *SQLCGeneratorParams) GetPluginFilePath() string

GetPluginFilePath returns the plugin file path.

Directories

Path Synopsis
internal
gen command

Jump to

Keyboard shortcuts

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