• Stars
    star
    106
  • Rank 323,351 (Top 7 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ActiveRecord Stand-alone Migrations (for non-Rails projects)

ActiveRecord Stand-alone Migrations

Allows you to use ActiveRecord migrations in non-Rails projects.

Installation

Add this line to your application's Gemfile (run bundle init if you don't have one):

gem 'active_record_migrations'
gem 'sqlite3' # or 'pg', 'mysql2', ...

And then execute:

$ bundle --binstubs

Create a Rakefile:

require 'active_record_migrations'
ActiveRecordMigrations.load_tasks

Usage

By default, your database configurations will be read from db/config.yml and your migration files will be created under db/migrate. If you want to keep with the defaults, create your db/config.yml:

    development:
      adapter: postgresql
      database: my_db
      encoding: utf8
      host: localhost
      port: 5432
      username: noel
      password: s3cret
    test:
      adapter: sqlite3
      database: db/test.sqlite3
      pool: 5
      timeout: 5000

If you prefer to specify your settings in plain Ruby, add this to your Rakefile, before calling ActiveRecordMigrations.load_tasks:

ActiveRecordMigrations.configure do |c|
  c.database_configuration = {
    'development' => {'adapter' => 'sqlite3', 'database' => 'db/custom.sqlite3'},
  }
  # Other settings:
  c.schema_format = :sql # default is :ruby
  # c.yaml_config = 'db/config.yml'
  # c.environment = ENV['db']
  # c.db_dir = 'db'
  # c.migrations_paths = ['db/migrate'] # the first entry will be used by the generator
end

Take a look at the Migrations Guide for more details.

The main difference is that instead of rails generate migration (or rails g migration), the generator is implemented as a Rake task. So you should use it like rake "db:new_migration[CreateUser, name birth:date]" (double quotes are required if you use this form). Alternatively you could run it as rake db:new_migration name=CreateUser options="name birth:date".

Just run rake db:new_migration for help on usage.

You can specify the environment by setting the db environment variable:

rake db:migrate db=production

Versioning

From ActiveRecord 5.0.2 and above you should use v5.0.2.1 or above. That version isn't locked to ActiveRecord 5.0.2 as in previous versions, which means it should work fine with any ActiveRecord version starting with 5.0.2.

Up to ActiveRecord 5.0.1 we relied on overriding a method in the migration generator to support custom paths for the migrations, so the version used to follow ActiveRecord versions plus a patch version from our own. For instance, if AR version is 4.0.1, this gem would be versioned 4.0.1.x with x starting in 0.

I can't find a release for the AR version we rely on

We had to use pessimistic versioning up to 5.0.1.1 because we relied on internal details of AR migrations in order to override the migrations path. The optimistic branch should work with any previous version since ActiveRecord 4.0.0.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

More Repositories

1

gitorious-cookbooks

Cookbooks collection for being used by Gitorious and chef-solo
Ruby
71
star
2

auto_reloader

A transparent code reloader.
Ruby
59
star
3

rails-web-console

A web-based Rails console
Ruby
55
star
4

conque-term

git-svn mirror of http://code.google.com/p/conque/
Python
48
star
5

sequel_tools

Tools to help with managing database operations with Sequel through Rake tasks
Ruby
45
star
6

rspec_nested_transactions

Nested Transactions around before/after(:all) blocks too besides examples for RSpec
Ruby
37
star
7

rack_web_console

A web console for Rack apps.
Ruby
30
star
8

rack_toolkit

A dynamic Rack server and helper methods to help testing Rack apps.
Ruby
17
star
9

light_blog

LightBlog: a file-based blog app written in Ruby
Ruby
16
star
10

sequel-devise

Devise support for Sequel models
Ruby
15
star
11

vimfiles

vim configuration files
Vim Script
10
star
12

hotkeys-manager

Global Hotkeys web manager for Linux/X11
Ruby
9
star
13

simple_mail_builder

A simple TEXT+HTML multipart mail message builder to be delivered to SMTP or sendmail for Ruby
Ruby
8
star
14

oojspec

Object-oriented client-side (JavaScript or CoffeeScript) testing
CoffeeScript
6
star
15

cert-generator

Docker container to generate auto-signed dev suited root CA and certificates from web interface
Ruby
6
star
16

rails_compatible_cookies_utils

Provides utility methods to read and write cookies shared with a Rails app
Ruby
5
star
17

manga-downloadr-test-performance-mode

Manga Downloader Performance Test Mode in Ruby
Ruby
5
star
18

jquery-layout-rails

jQuery-layout plugin as a Rails engine
Ruby
4
star
19

chords-processor

Chords Processor
JavaScript
4
star
20

command-reference

Miscelaneous tips with command references for various tasks
3
star
21

fake-ajax-server

Fake Ajax Server for jQuery requests to be used in integration JavaScript tests/specs
Ruby
2
star
22

jasmine-node-jquery-matchers

jQuery Matchers for Jasmine under Node.js
CoffeeScript
2
star
23

common-dialogs

Common JavaScript asynchronous dialog alternatives to alert, confirm and prompt
CoffeeScript
2
star
24

rails-sandbox-assets

Create your own spec runner taking advantage of the Rails asset pipeline
Ruby
2
star
25

jquery-ajax-callback-example

Demonstrates $.post callback without a content-type in the response
Ruby
1
star
26

harmonias

Harmonias de músicas
CoffeeScript
1
star
27

rails_sandbox_jasmine

Run your Jasmine specs in a sandboxed environment while taking advantage of the Asset Pipeline of your Rails application
Ruby
1
star
28

interactivemock

Grails application sample for demonstrating a bug while using mocks for tests under the interactive console
Groovy
1
star
29

mixed_test_runners

Example of application using both Jasmine and Mocha/Chai spec runners on top of rails-sandbox-assets
Ruby
1
star
30

rails_error_pages_br

Rails error pages translated to Brazilian Portuguese
1
star
31

grails-bug-setter-assignment-in-constructor

Demonstrate a recent bug in Grails with regards to default constructor and mass-assignment of overriden properties
Groovy
1
star
32

git-spell-pt-br

pt-BR vim spell file based on BrOffice.org Vero plugin
1
star
33

grails_bug_console

LazyInitializationException in Grails Console example
Groovy
1
star
34

rails-routes-issues

Some inconsistencies on Rails routes
Ruby
1
star
35

sequel-ar-example

Example application demonstrating differences between ActiveRecord and Sequel
Ruby
1
star
36

movable-columns

Movable Columns
JavaScript
1
star
37

ctbenchmark

Catch-throw benchmark on Rails
Ruby
1
star
38

fix-lame-id3-generated-by-k3b

Fix id3 tag encodings generated by lame in K3b
Ruby
1
star
39

grails_bug_selfreference

Demonstrates a bug where unit test will pass (correctly) but integration will fail (should pass)
Groovy
1
star
40

firebug-lite

Stable version of firebug-lite
JavaScript
1
star
41

activerecord-example

ActiveRecord example without Rails and with Migrations
Ruby
1
star
42

oojspec-test

oojspec example application
Ruby
1
star
43

grails-oojs

An example on how to use oojs with a Grails application
Groovy
1
star
44

js-modules

Split your JavaScript "classes" in multiple files
CoffeeScript
1
star
45

grails_bug_reloadingWithEvents

Another Grails bug example
Groovy
1
star
46

ktrayshortcut

Send X11 applications to tray and assign them global shortcuts
C++
1
star
47

rails-sandbox-busterjs

Buster.js test runner for the Rails asset pipeline
Ruby
1
star
48

grails_bug_unitfails

Grails Bug: unit tests failing
Groovy
1
star
49

rails-template-streaming-invalid-csrf-bug

Application demonstrating issue with usage of streaming templates and CSRF token validation
Ruby
1
star
50

oojs_assets_enabler

Enable the Rails asset pipeline with Jasmine support in your non-Rails app
Ruby
1
star
51

sample-jbundler

A fresh Rails application with jbundler integration
Ruby
1
star
52

rails_sandbox_mocha_chai

Mocha/Chai specs in an isolated server for your Rails application that can take advantage of the asset pipeline
Ruby
1
star
53

oojs

Object-oriented JavaScript (or CoffeeScript) programming with test coverage
CoffeeScript
1
star
54

konacha_reuse

Demonstrates how to create a konacha-like engine on top of rails_sandbox_mocha_chai
Ruby
1
star
55

konacha_like

Demonstrates how to create a konacha-like engine on top of rails-sandbox-assets
Ruby
1
star