mysql

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package mysql provides the MySQL dialect, which also serves MariaDB.

Importing it registers the dialect under "mysql" and "mariadb":

import _ "github.com/gruberchris/rung/dialect/mysql"

MariaDB is served by this dialect because it speaks the same wire protocol and the same SQL. It is a fork rather than a version, though, so it is worth verifying separately in CI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialect

type Dialect struct{}

Dialect implements rung.Dialect for MySQL 8.0+ and MariaDB 10.5+.

func (Dialect) DropTablesStatement

func (Dialect) DropTablesStatement(quoted []string) string

DropTablesStatement drops every named table.

MySQL has no CASCADE, so foreign key checks are suspended for the duration rather than a safe drop order being computed. The statement relies on the multi-statement connection Dialect.OpenForMigrations returns.

func (Dialect) LedgerDDL

func (Dialect) LedgerDDL() string

LedgerDDL creates the migration ledger, mirroring the PostgreSQL one row for row.

DATETIME(6) rather than TIMESTAMP: MySQL's TIMESTAMP converts to and from the session time zone and tops out in 2038, and neither is wanted for a record of what has been applied to a schema.

func (Dialect) LedgerExistsQuery

func (Dialect) LedgerExistsQuery() string

LedgerExistsQuery reports whether the ledger exists in the connected database.

The TABLE_SCHEMA = DATABASE() predicate is load-bearing: without it the query reports a _migrations table belonging to some other database on the same server.

func (Dialect) ListTablesQuery

func (Dialect) ListTablesQuery() string

ListTablesQuery lists the tables in the connected database, for rung/reset.

func (Dialect) MigrationsDir

func (Dialect) MigrationsDir() string

MigrationsDir returns "mysql". MariaDB runs the same file set.

func (Dialect) Name

func (Dialect) Name() string

Name returns the canonical driver name.

func (Dialect) OpenForMigrations

func (Dialect) OpenForMigrations(dsn string) (*sql.DB, error)

OpenForMigrations opens a handle permitting several statements per Exec.

A migration file needs that and ordinary traffic must never have it: it is the difference between a driver that can reject an injected statement and one that cannot.

ParseTime and a UTC location are forced rather than left to the caller's DSN. Without ParseTime the driver returns DATETIME columns as []byte and every scan into a time.Time fails; without Loc it reads them in the server's local zone, silently shifting every timestamp by the deployment's UTC offset. Both are configuration mistakes that surface far from their cause.

func (Dialect) QuoteIdentifier

func (Dialect) QuoteIdentifier(name string) string

QuoteIdentifier quotes a SQL identifier with backticks.

func (Dialect) Rebind

func (Dialect) Rebind(query string) string

Rebind returns the query unchanged; MySQL already uses ? placeholders.

Jump to

Keyboard shortcuts

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