Coder Social home page Coder Social logo

flamingo-mysql's Introduction

Flamingo MySQL module

Go Report Card GoDoc Tests Release

This flamingo module provides a simple MySQL implementation by wrapping github.com/jmoiron/sqlx and a migration tool by wrapping github.com/golang-migrate/migrate as Flamingo Modules.

DB Module

The DB Flamingo module provides the interface DB and binds an sqlx connection as singleton to it. The module will panic on startup when the connection can't be established.

Configuration

db:
  host: "host"
  port: "3306" # must be a string!
  databaseName: "databaseName"
  user: "user"
  password: "password"
  maxConnectionLifetime: 0 # in seconds, 0 means to set nothing, negative values mean unlimited
  # a set of additional connection options which are added as parameters to the DB URL
  connectionOptions: 
    myOption1: "myValue1" # all option values must be strings
    myOption2: "false"

Migration Module

The migration module relies on the db module and can handle schema migration and data seeding scripts. Both must be provided as simple SQL scripts.

The module provides additional Flamingo commands as entrypoints:

  • migrate [up|down] (-s[number of steps])
  • seed

Configuration

migrations:
  automigrate: false,
  directory:   "sql/migrations/",
seeds:
  directory:   "sql/seeds/",

The Migration Module also adds "db.connectionOptions.multiStatements": "true" to the db configuration to handle migration and seed scripts.

Migration

Migration scripts must be placed into the configured directory. For each migration, there must be an "up" and a "down" script. Please refer to github.com/golang-migrate/migrate for more detailed documentation.

If you set the automigrate config to true, flamingo will run a migrate up on each application start (flamingo.StartupEvent).

Seeding

Seeding scripts must be placed into the configured directory. The seed command runs all scripts in lexical order (see filepath.Walk).

Example directory structure:

sql
├── migrations
│   ├── 1_usertable.up.sql
│   ├── 1_usertable.down.sql
│   ├── 2_other-table.up.sql
│   ├── 2_other-table.down.sql
│   ├── 3_usertable-addColumn.up.sql
│   └── 3_usertable-addColumn.down.sql
└── seeds
    ├── users.sql
    └── other-data.sql

flamingo-mysql's People

Contributors

bastianccm avatar github-actions[bot] avatar renovate[bot] avatar tessig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flamingo-mysql's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/golangci-lint.yml
  • actions/checkout v4
  • actions/setup-go v5
  • golangci/golangci-lint-action v6
.github/workflows/main.yml
  • actions/checkout v4
  • actions/setup-go v5
  • actions/checkout v4
  • actions/setup-go v5
  • irongut/CodeCoverageSummary v1.3.0
  • marocchino/sticky-pull-request-comment v2
.github/workflows/semanticore.yml
  • actions/checkout v4
  • actions/setup-go v5
gomod
go.mod
  • go 1.21
  • go 1.22.3
  • flamingo.me/dingo v0.2.10
  • flamingo.me/flamingo/v3 v3.8.1
  • github.com/DATA-DOG/go-sqlmock v1.5.2
  • github.com/go-sql-driver/mysql v1.8.1
  • github.com/golang-migrate/migrate/v4 v4.17.1
  • github.com/jmoiron/sqlx v1.4.0
  • github.com/spf13/cobra v1.8.0
  • github.com/stretchr/testify v1.9.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.