Sha256: 8da97d622443650c05a7a9c191fcf830842c858a7089c3e1358575feb28de731

Contents?: true

Size: 856 Bytes

Versions: 5

Compression:

Stored size: 856 Bytes

Contents

db = {
  :adapter=>'sqlite3',
  :dbfile=> File.join(File.dirname(__FILE__),'..','spec','db','test.db')
}
ActiveRecord::Base.establish_connection( db )
# define a migration
class TestSchema < ActiveRecord::Migration
  def self.up
    create_table :categories do |t|
      t.string :name
      t.timestamps
    end
    create_table :items do |t|
      t.string :title
      t.string :slug
      t.string :permalink
      t.boolean :published
      t.integer :category_id
      t.timestamps
    end
  end

  def self.down
    drop_table :items
  end
end


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

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
ismasan-sluggable_finder-2.0.3 tasks/db.rake
ismasan-sluggable_finder-2.0.4 tasks/db.rake
ismasan-sluggable_finder-2.0.5 tasks/db.rake
ismasan-sluggable_finder-2.0.6 tasks/db.rake
nagybence-sluggable_finder-2.0.6 tasks/db.rake