Sha256: 611f81096f9ae5468e55dfcda26319fd0646841ab6e55107997698c284a707df
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
require 'active_record' db = { :adapter=>'sqlite3', :dbfile=> File.join(File.dirname(__FILE__),'..','spec','db','test.db'), :host => 'localhost', :database => 'spec/db/sluggable_finder_test', :user => 'root', :password => '' } 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 :type t.string :permalink t.boolean :published t.integer :category_id t.timestamps end end def self.down drop_table :items drop_table :categories end end namespace :db do desc "Create test schema" task :create do # run the migration File.unlink(db[:dbfile]) if db[:adapter] == 'sqlite3' && 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
sluggable_finder-2.3.5 | tasks/db.rake |
sluggable_finder-2.3.4 | tasks/db.rake |
sluggable_finder-2.3.3 | tasks/db.rake |
sluggable_finder-2.3.2 | tasks/db.rake |