Giter Site home page Giter Site logo

ragtime-cli's Introduction

ragtime-cli

Ragtime Commandline Tools compiled as executable using GraalVM.

Duct Framework is a great framework overall, especially in development time. However, it is just a bit too slow when it starts or migrates in production or CI test. By compiling Ragtime to binary, I could at least save half of my CI/CD time (also money)! And I hope this tools could give others the same benefit!

Usage

You can use it as a commandline tools for db migration.

# command use environment vars
export DATABASE_URL=jdbc:postgresql://localhost:5432/postgres?user=postgres&password=abcd1234
export RESOURCES_DIR=migrations/
export CONFIG_FILE=resources/config.edn
# test connection
ragtime-cli q "select 1"
# show the diff between db and migrations
ragtime-cli info
# migrate
ragtime-cli migrate-all
# rollback-to
ragtime-cli rollback-to <migration-id>
# rollback-last
ragtime-cli rollback-last <n-migrations>
# help
ragtime-cli --help

But it is more useful when used in CI/CD steps or AWS Lambda. ragtime-cli is already packaged as for lambda deployment.

Package with function

# Download the zip
curl -L https://github.com/zerg000000/ragtime-cli/releases/download/v0.0.4/lambda-ubuntu-latest-postgres.zip -o lambda.zip

# If you are using duct framework, add config.edn and migrations/ to the zip file
zip -ur lambda.zip resources/<project>/config.edn resources/migrations/

# Create Lambda function
aws lambda create-function --function-name db-migration \
--zip-file fileb://lambda.zip --handler index.handler --runtime provided \
--environment Variables="{DATABASE_URL=abc,CONFIG_FILE=resources/<project>/config.edn,RESOURCES_DIR=resources/}" \
--role arn:aws:iam::123456789012:role/lambda-cli-role

Use as a layer

# Download the zip
curl -L https://github.com/zerg000000/ragtime-cli/releases/download/v0.0.4/lambda-ubuntu-latest-postgres.zip -o lambda.zip

# Publish as a layer
aws lambda publish-layer-version --layer-name ragtime-runtime --zip-file fileb://lambda.zip

# Bundle all your migrations files
zip migrations.zip resources/<project>/config.edn resources/migrations/

# Create Lambda function
aws lambda create-function --function-name db-migration \
--layers arn:aws:lambda:us-west-2:123456789012:layer:ragtime-runtime:1 \
--environment Variables="{DATABASE_URL=abc,CONFIG_FILE=resources/<project>/config.edn,RESOURCES_DIR=resources/}" \
 --zip-file fileb://migrations.zip

Limitation

Currently, only support/tested on linux/mac and postgres. If your Duct config is not so common, this commandline might not work for you.

License

Copyright © 2019 Albert Lai

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

ragtime-cli's People

Contributors

zerg000000 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

ragtime-cli's Issues

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.