Sha256: 17354018f82ad68b0347d8655602083cc5295b252f2c62a4b8bbd89a316bbd00

Contents?: true

Size: 1.19 KB

Versions: 10

Compression:

Stored size: 1.19 KB

Contents

database_config = {
  :adapter=>'sqlite3',
  :dbfile=> File.join(File.dirname(__FILE__),'..','spec','db','test.db')
}

ActiveRecord::Base.establish_connection(database_config)
# define a migration
class TestSchema < ActiveRecord::Migration
  def self.up
    create_table :posts do |t|
      t.string :title
      t.boolean  :is_published
      t.datetime :publish_at
      t.datetime :unpublish_at
      t.timestamps
    end
    
    create_table :articles do |t|
      t.string :title
      t.boolean  :is_published
      t.datetime :publish_at
      t.datetime :unpublish_at
      t.timestamps
    end
    
    create_table :comments do |t|
      t.text :body
      t.boolean  :is_published
      t.integer :post_id
      t.datetime :publish_at
      t.datetime :unpublish_at
      t.timestamps
    end
  end

  def self.down
    drop_table :posts
    drop_table :comments
    drop_table :articles
  end
end


namespace :db do
  desc "migrate test schema"
  task :create do
    File.unlink(database_config[:dbfile])
    ActiveRecord::Base.connection # this creates the DB
    # run the migration
    TestSchema.migrate(:up)
  end
  
  desc "Destroy test schema"
  task :destroy do
    TestSchema.migrate(:down)
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
ismasan-ar_publish_control-0.0.3 tasks/db.rake
ismasan-ar_publish_control-0.0.4 tasks/db.rake
ismasan-ar_publish_control-0.0.5 tasks/db.rake
ismasan-ar_publish_control-0.0.6 tasks/db.rake
ismasan-ar_publish_control-0.0.7 tasks/db.rake
ismasan-ar_publish_control-0.0.8 tasks/db.rake
ismasan-ar_publish_control-0.0.9 tasks/db.rake
oktoberliner-ar_publish_control_with_scopes-0.0.1 tasks/db.rake
oktoberliner-ar_publish_control_with_scopes-0.0.2 tasks/db.rake
ar_publish_control-0.0.9 tasks/db.rake