mysql

package
v0.44.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package mysql is the MySQL/MariaDB DB driver.

MySQL placeholder syntax (?) matches SQLite, so this driver wraps the SQLite Store implementation and only swaps the migrations FS, dialect, and DSN handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeDSN

func NormalizeDSN(dsn string) string

NormalizeDSN fills in the three settings every statement in filex assumes, so an operator who writes a bare DSN gets a working server rather than a subtly wrong one.

  • parseTime — without it every DATETIME scans into []byte and the row scan fails.
  • loc=UTC — how a Go time.Time is rendered on the way in.
  • time_zone='+00:00' — what the SERVER thinks now() is. The two are independent: with only loc=UTC, CURRENT_TIMESTAMP defaults and comparisons still run in the server's local zone, so a queued op's not_before (written as a UTC string) would be read hours early or late.

An explicit value in the DSN always wins; this only adds what is missing.

Types

type Driver

type Driver struct{}

Driver implements db.Driver for MySQL/MariaDB.

func (Driver) Dialect

func (Driver) Dialect() string

Dialect for goose.

func (Driver) MigrationsFS

func (Driver) MigrationsFS() embed.FS

MigrationsFS returns the embedded MySQL migrations.

func (Driver) Name

func (Driver) Name() string

Name implements db.Driver.

func (Driver) NewStore

func (Driver) NewStore(sqlDB *sql.DB) db.Store

NewStore reuses the SQLite Store in MySQL mode: the placeholder syntax (?), the column names and the CURRENT_TIMESTAMP literals are shared, and the one construct the two engines spell differently — the upsert — is rewritten by sqlite.Store.upsert rather than kept as a second copy of every statement.

⚠ That sharing is only true while someone checks it. It was not checked until issue #19, and by then MySQL could not create its schema at all, let alone write to it. backend/internal/db runs the migrations, a schema-parity comparison and the first-five-minutes write path against a real MySQL server; point FILEX_TEST_MYSQL_DSN at one before trusting a change here.

func (Driver) Open

func (Driver) Open(_ context.Context, dsn string) (*sql.DB, error)

Open returns a configured *sql.DB.

DSN format: `user:pass@tcp(host:3306)/dbname?parseTime=true&loc=UTC&charset=utf8mb4`

Jump to

Keyboard shortcuts

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