Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

[DEPRECATED - use mini_record] Declare a table structure like an ActiveRecord migration and run 'force_schema!' whenever you want. For when you don't need up and down migrations.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 force_schema.gemspec
README.rdoc

force_schema

class Car < ActiveRecord::Base
  set_primary_key :name
  force_schema do
    string   'name'       # Nissan Altima, will automatically be indexed because it's the primary key
    string   'make_name'  # Nissan
    string   'model_name' # Altime
    float    'fuel_efficiency_city'
    string   'fuel_efficiency_city_units'
    float    'fuel_efficiency_highway'
    string   'fuel_efficiency_highway_units'
    integer  'year'
    datetime 'released_at'
    date     'released_on'
    index    ['name', 'make_name']
  end
end

Warning: data loss

If you call Car.force_schema!, it may destroy data by adding, removing, or changing the type of columns. No attempt is made to preserve data.

What it synchronizes

  • adds missing columns

  • adds missing indexes

  • removes unrecognized columns

  • removes unrecognized indexes

  • changes the type of columns if it doesn't match what you asked for

  • changes the columns indexed if they don't match what you asked for

  • makes sure default value is synced up

Supported databases

  • MySQL is tested

  • SQLite is tested

  • Postgres is not supported

History

Extracted from github.com/seamusabshere/data_miner. In production use at carbon.brighterplanet.com and data.brighterplanet.com.

Copyright 2011 Seamus Abshere

Something went wrong with that request. Please try again.