Coder Social home page Coder Social logo

eloquent-migrator's Introduction

eloquent-migrator

Simple db migrator that uses Laravel's db layer.

Usage via docker-compose

  • Run make build start
  • Check the migrator logs with docker logs -f eloquent_migrator

Usage via docker run

  • Run docker build . -t eloquent-migrator
  • Run docker run --env-file docker.env eloquent-migrator

Usage without docker

  • Modify config.php to replace $_ENV values with actual values
  • Run composer install
  • Run php runMigrations.php

Adding new schemas

Adding updates

  • Create a new class under src/Database/Updates that implements either AlterInterface (plain MySql alters) or UpdateInterface (supports blueprints)
  • See existing examples
  • See eloquent documentation https://laravel.com/docs/5.7/migrations#column-modifiers
  • Add the new update to the UPDATES_LIST config in config.php

Adding content

  • Create a new class under src/Database/Content that implements ContentInterface
  • See existing examples
  • Existing strategies:
    • insert - will generate an insert query based on the data you provided
    • truncate-insert - will truncate the table then insert the data
    • insert-ignore - will attempt to insert and ignore duplicate key errors if any
  • Add the new update to the CONTENT_LIST config in config.php

Required environment variables (docker.env):

  • MYSQL_HOST
  • MYSQL_PORT
  • MYSQL_DATABASE
  • MYSQL_USER
  • MYSQL_PASSWORD
  • ENVIRONMENT - use prod as value for production environments

Optional environment variables

  • DB_CONNECT_MAX_RETRIES - after how many failed db connection should it shutdown, defaults to 10
  • DB_CONNECT_RETRY_TIME - how much should the app wait until to attempt a reconnect, defaults to 10

eloquent-migrator's People

Contributors

svalexcicioc avatar alexcicioc avatar

Stargazers

 avatar

Watchers

 avatar

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.