github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

citrusbyte / schemer

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 3
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (5)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (5)
    • 0.0.10
    • 0.0.9
    • 0.0.8
    • 0.0.7
    • 0.0.6
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

On-the-fly ActiveRecord schema changes for extremely rapid prototyping. — Read more

  cancel

http://labs.citrusbyte.com/projects/schemer

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

columns now update on type change automatically 
benalavi (author)
Sun Jul 05 19:54:43 -0700 2009
commit  8b07ff259a49e8a8312b9bf52faf092aa9e2ecb6
tree    4c770149cf8c24b633f5e7f10e78687f56417606
parent  5d0dca565d41edc65905737147be0aad7cc876c2
schemer /
name age
history
message
file .gitignore Loading commit data...
file LICENSE
file README.markdown
file Rakefile
directory lib/
directory rails/
file schemer.gemspec
file schemer.gemspec.erb
directory test/
README.markdown

Schemer

On-the-fly ActiveRecord schema changes for extremely rapid prototyping.

Description

Loosely define your schema in your ActiveRecord model and have it created and updated for you without worrying about migrations. Useful for when you want to play around with real data handling during prototyping but you really don't care about keeping the data or how it's defined.

This isn't meant to be a replacement for migrations, it is simply a way to get started on a project quickly while you iron out your data definitions.

WARNING: This will create and delete data definitions on the fly with no warning! Only use this with volatile data! Never attach it to an existing model you care about as it will start adding and dropping columns without your consent!

Usage

class User < ActiveRecord::Base
  schema :username, :password
end

Creates a users table if it doesn't exist, complete with username and password columns the first time the User class is loaded.

Need another column to play with?

class User < ActiveRecord::Base
  schema :username, :password, :email
end

Adds an email column the next time User class is loaded.

Want a relationship? (but fear commitment...)

class Widget < ActiveRecord::Base
  schema :user_id, :name

  belongs_to :user
end

Works just fine, and you can drop it at any time!

class Widget < ActiveRecord::Base
  schema :name
end

Removes the user_id column the next time the Widget class is loaded.

Have a need for a particular type of column?

class Widget < ActiveRecord::Base
  schema :name, { :size => :integer }, :description
end

Will create size as an :integer column so you can take advantage of Rails' casting.

Feeling more confident and ready to make that big leap to migrations? Just run:

rake schemer:migration

To get:

Migration from schema declarations in User, Widget

create_table :users do |t|
  t.string :username
  t.string :password
  t.string :email
end

create_table :widgets do |t|
  t.string :name
  t.integer :size
  t.string :description
end

Then you can paste the output into a migration file, setup your columns (don't forget your indexes!) and get rid of your schema calls in the listed classes and you're on your way to the big leagues!

NOTE: All columns are created as string columns unless type is given.

Installation

$ sudo gem install citrusbyte-schemer --source=http://gems.github.com

License

Copyright (c) 2009 Ben Alavi for Citrusbyte

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server