ardm-migrations 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/.travis.yml +11 -0
- data/Gemfile +53 -0
- data/LICENSE +20 -0
- data/README.rdoc +39 -0
- data/Rakefile +4 -0
- data/ardm-migrations.gemspec +27 -0
- data/db/migrations/1_create_people_table.rb +12 -0
- data/db/migrations/2_add_dob_to_people.rb +13 -0
- data/db/migrations/config.rb +4 -0
- data/examples/Rakefile +144 -0
- data/examples/sample_migration.rb +58 -0
- data/examples/sample_migration_spec.rb +50 -0
- data/lib/ardm-migrations.rb +1 -0
- data/lib/dm-migrations/adapters/dm-do-adapter.rb +295 -0
- data/lib/dm-migrations/adapters/dm-mysql-adapter.rb +299 -0
- data/lib/dm-migrations/adapters/dm-oracle-adapter.rb +332 -0
- data/lib/dm-migrations/adapters/dm-postgres-adapter.rb +159 -0
- data/lib/dm-migrations/adapters/dm-sqlite-adapter.rb +96 -0
- data/lib/dm-migrations/adapters/dm-sqlserver-adapter.rb +177 -0
- data/lib/dm-migrations/adapters/dm-yaml-adapter.rb +23 -0
- data/lib/dm-migrations/auto_migration.rb +239 -0
- data/lib/dm-migrations/exceptions/duplicate_migration.rb +6 -0
- data/lib/dm-migrations/migration.rb +300 -0
- data/lib/dm-migrations/migration_runner.rb +85 -0
- data/lib/dm-migrations/sql/column.rb +5 -0
- data/lib/dm-migrations/sql/mysql.rb +61 -0
- data/lib/dm-migrations/sql/postgres.rb +82 -0
- data/lib/dm-migrations/sql/sqlite.rb +51 -0
- data/lib/dm-migrations/sql/table.rb +15 -0
- data/lib/dm-migrations/sql/table_creator.rb +109 -0
- data/lib/dm-migrations/sql/table_modifier.rb +57 -0
- data/lib/dm-migrations/sql.rb +5 -0
- data/lib/dm-migrations/version.rb +5 -0
- data/lib/dm-migrations.rb +3 -0
- data/lib/spec/example/migration_example_group.rb +73 -0
- data/lib/spec/matchers/migration_matchers.rb +106 -0
- data/spec/integration/auto_migration_spec.rb +553 -0
- data/spec/integration/auto_upgrade_spec.rb +40 -0
- data/spec/integration/migration_runner_spec.rb +89 -0
- data/spec/integration/migration_spec.rb +157 -0
- data/spec/integration/sql_spec.rb +250 -0
- data/spec/isolated/require_after_setup_spec.rb +30 -0
- data/spec/isolated/require_before_setup_spec.rb +30 -0
- data/spec/isolated/require_spec.rb +25 -0
- data/spec/rcov.opts +6 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/unit/migration_spec.rb +453 -0
- data/spec/unit/sql/column_spec.rb +14 -0
- data/spec/unit/sql/postgres_spec.rb +97 -0
- data/spec/unit/sql/sqlite_extensions_spec.rb +108 -0
- data/spec/unit/sql/table_creator_spec.rb +94 -0
- data/spec/unit/sql/table_modifier_spec.rb +49 -0
- data/spec/unit/sql/table_spec.rb +28 -0
- data/spec/unit/sql_spec.rb +7 -0
- data/tasks/spec.rake +38 -0
- data/tasks/yard.rake +9 -0
- data/tasks/yardstick.rake +19 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 92f93f472dab02d31afe97f1eeb7a8c678bf93dd
|
4
|
+
data.tar.gz: ef8affab3f303cb35f70529616936114d0d0aa54
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49bc21cc18de995796d5755f80c305a0daf4b7ab69610e3d7561e04c07c699bc9ca2686b61845326978161249f56cd3da45d5caa798a97201dd095283aff0333
|
7
|
+
data.tar.gz: 6feded039b1f6a3afd3868ab600b240d46ca2d6dab1a8184c4e13d55de1ba905a1b9563ad61b242c35810351ba5a6d8357f729dbb44afdbbca60b4c7c72f05fd
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## Rubinius
|
17
|
+
*.rbc
|
18
|
+
|
19
|
+
## PROJECT::GENERAL
|
20
|
+
*.gem
|
21
|
+
coverage
|
22
|
+
rdoc
|
23
|
+
pkg
|
24
|
+
tmp
|
25
|
+
doc
|
26
|
+
log
|
27
|
+
.yardoc
|
28
|
+
measurements
|
29
|
+
|
30
|
+
## BUNDLER
|
31
|
+
.bundle
|
32
|
+
Gemfile.*
|
33
|
+
|
34
|
+
## PROJECT::SPECIFIC
|
35
|
+
spec/db/
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
SOURCE = ENV.fetch('SOURCE', :git).to_sym
|
8
|
+
REPO_POSTFIX = SOURCE == :path ? '' : '.git'
|
9
|
+
DATAMAPPER = SOURCE == :path ? Pathname(__FILE__).dirname.parent : 'http://github.com/ar-dm'
|
10
|
+
DM_VERSION = '~> 1.2.0'
|
11
|
+
DO_VERSION = '~> 0.10.6'
|
12
|
+
DM_DO_ADAPTERS = %w[ sqlite postgres mysql oracle sqlserver ]
|
13
|
+
CURRENT_BRANCH = ENV.fetch('GIT_BRANCH', 'master')
|
14
|
+
|
15
|
+
gem 'ardm-core', DM_VERSION, SOURCE => "#{DATAMAPPER}/ardm-core#{REPO_POSTFIX}", :branch => CURRENT_BRANCH
|
16
|
+
|
17
|
+
group :datamapper do
|
18
|
+
|
19
|
+
adapters = ENV['ADAPTER'] || ENV['ADAPTERS']
|
20
|
+
adapters = adapters.to_s.tr(',', ' ').split.uniq - %w[ in_memory ]
|
21
|
+
|
22
|
+
if (do_adapters = DM_DO_ADAPTERS & adapters).any?
|
23
|
+
do_options = {}
|
24
|
+
do_options[:git] = "#{DATAMAPPER}/do#{REPO_POSTFIX}" if ENV['DO_GIT'] == 'true'
|
25
|
+
|
26
|
+
gem 'data_objects', DO_VERSION, do_options.dup
|
27
|
+
|
28
|
+
do_adapters.each do |adapter|
|
29
|
+
adapter = 'sqlite3' if adapter == 'sqlite'
|
30
|
+
gem "do_#{adapter}", DO_VERSION, do_options.dup
|
31
|
+
end
|
32
|
+
|
33
|
+
gem 'ardm-do-adapter', DM_VERSION,
|
34
|
+
SOURCE => "#{DATAMAPPER}/ardm-do-adapter#{REPO_POSTFIX}",
|
35
|
+
:branch => CURRENT_BRANCH
|
36
|
+
end
|
37
|
+
|
38
|
+
adapters.each do |adapter|
|
39
|
+
gem "ardm-#{adapter}-adapter", DM_VERSION,
|
40
|
+
SOURCE => "#{DATAMAPPER}/ardm-#{adapter}-adapter#{REPO_POSTFIX}",
|
41
|
+
:branch => CURRENT_BRANCH
|
42
|
+
end
|
43
|
+
|
44
|
+
plugins = ENV['PLUGINS'] || ENV['PLUGIN']
|
45
|
+
plugins = plugins.to_s.tr(',', ' ').split.uniq
|
46
|
+
|
47
|
+
plugins.each do |plugin|
|
48
|
+
gem plugin, DM_VERSION,
|
49
|
+
SOURCE => "#{DATAMAPPER}/#{plugin}#{REPO_POSTFIX}",
|
50
|
+
:branch => CURRENT_BRANCH
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Paul Sadauskas
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
= dm-migrations
|
2
|
+
|
3
|
+
DataMapper plugin for writing and specing migrations.
|
4
|
+
|
5
|
+
== Example
|
6
|
+
|
7
|
+
require 'dm-migrations/migration_runner'
|
8
|
+
|
9
|
+
DataMapper.setup(:default, "sqlite3::memory")
|
10
|
+
|
11
|
+
DataMapper::Logger.new(STDOUT, :debug)
|
12
|
+
DataMapper.logger.debug( "Starting Migration" )
|
13
|
+
|
14
|
+
migration 1, :create_people_table do
|
15
|
+
up do
|
16
|
+
create_table :people do
|
17
|
+
column :id, Integer, :serial => true
|
18
|
+
column :desc, String
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
down do
|
23
|
+
drop_table :people
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
migration 2, :make_desc_text do
|
28
|
+
up do
|
29
|
+
modify_table :people do
|
30
|
+
# You currently have to use the underlying DB type here, rather than
|
31
|
+
# a DataMapper type
|
32
|
+
change_column :desc, 'text'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
migrate_up!
|
38
|
+
|
39
|
+
For more, see the examples directory.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/dm-migrations/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'ardm-migrations'
|
6
|
+
gem.version = DataMapper::Migrations::VERSION
|
7
|
+
|
8
|
+
gem.authors = ["Martin Emde", "Paul Sadauskas"]
|
9
|
+
gem.email = ['me@martinemde.com', 'psadauskas [a] gmail [d] com']
|
10
|
+
gem.description = "Ardm fork of dm-migrations"
|
11
|
+
gem.summary = gem.description
|
12
|
+
gem.license = "MIT"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
16
|
+
gem.extra_rdoc_files = %w[LICENSE README.rdoc]
|
17
|
+
|
18
|
+
gem.homepage = "http://github.com/martinemde/ardm-migrations"
|
19
|
+
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
|
22
|
+
gem.add_runtime_dependency 'ardm-core', '~> 1.2'
|
23
|
+
|
24
|
+
gem.add_development_dependency 'rake', '~> 0.9'
|
25
|
+
gem.add_development_dependency 'rspec', '~> 1.3'
|
26
|
+
end
|
27
|
+
|
data/examples/Rakefile
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# Sample tasks using dm-migrations
|
2
|
+
# Roughly following Rails conventions, and mostly based on Padrino's dm:* tasks
|
3
|
+
#
|
4
|
+
# Cf. https://github.com/padrino/padrino-framework/blob/master/padrino-gen/lib/padrino-gen/padrino-tasks/datamapper.rb
|
5
|
+
# https://github.com/datamapper/dm-rails/blob/master/lib/dm-rails/railties/database.rake
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'rake'
|
9
|
+
|
10
|
+
# replace this with however your app configures DataMapper repositor(ies)
|
11
|
+
task :environment do
|
12
|
+
require File.expand_path('boot', File.dirname(__FILE__))
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :db do
|
16
|
+
|
17
|
+
namespace :auto do
|
18
|
+
|
19
|
+
desc "Perform auto-migration (reset your db data)"
|
20
|
+
task :migrate => :environment do |t, _|
|
21
|
+
puts "=> Auto-migrating"
|
22
|
+
::DataMapper.auto_migrate!
|
23
|
+
puts "<= #{t.name} done"
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Perform non destructive auto-migration"
|
27
|
+
task :upgrade => :environment do
|
28
|
+
puts "=> Auto-upgrading"
|
29
|
+
::DataMapper.auto_upgrade!
|
30
|
+
puts "<= #{t.name} done"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Run all pending migrations, or up to specified migration"
|
36
|
+
task :migrate, [:version] => :load_migrations do |t, args|
|
37
|
+
if vers = args[:version] || ENV['VERSION']
|
38
|
+
puts "=> Migrating up to version #{vers}"
|
39
|
+
migrate_up!(vers)
|
40
|
+
else
|
41
|
+
puts "=> Migrating up"
|
42
|
+
migrate_up!
|
43
|
+
end
|
44
|
+
puts "<= #{t.name} done"
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Rollback down to specified migration, or rollback last STEP=x migrations (default 1)"
|
48
|
+
task :rollback, [:version] => :load_migrations do |t, args|
|
49
|
+
if vers = args[:version] || ENV['VERSION']
|
50
|
+
puts "=> Rolling back down to migration #{vers}"
|
51
|
+
migrate_down!(vers)
|
52
|
+
else
|
53
|
+
step = ENV['STEP'].to_i || 1
|
54
|
+
applied = migrations.delete_if {|m| m.needs_up?}.sort # note this is N queries as currently implemented
|
55
|
+
target = applied[-1 * step] || applied[0]
|
56
|
+
if target
|
57
|
+
puts "=> Rolling back #{step} step(s)"
|
58
|
+
migrate_down!(target.position - 1)
|
59
|
+
else
|
60
|
+
warn "No migrations to rollback: #{step} step(s)"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
puts "<= #{t.name} done"
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "List migrations descending, showing which have been applied"
|
67
|
+
task :migrations => :load_migrations do
|
68
|
+
puts migrations.sort.reverse.map {|m| "#{m.position} #{m.name} #{m.needs_up? ? '' : 'APPLIED'}"}
|
69
|
+
end
|
70
|
+
|
71
|
+
task :load_migrations => :environment do
|
72
|
+
require 'dm-migrations/migration_runner'
|
73
|
+
FileList['db/migrate/*.rb'].each do |migration|
|
74
|
+
load migration
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
desc "Create the database"
|
80
|
+
task :create, [:repository] => :environment do |t, args|
|
81
|
+
repo = args[:repository] || ENV['REPOSITORY'] || :default
|
82
|
+
config = DataMapper.repository(repo).adapter.options.symbolize_keys
|
83
|
+
user, password, host = config[:user], config[:password], config[:host]
|
84
|
+
database = config[:database] || config[:path].sub(/\//, "")
|
85
|
+
charset = config[:charset] || ENV['CHARSET'] || 'utf8'
|
86
|
+
collation = config[:collation] || ENV['COLLATION'] || 'utf8_unicode_ci'
|
87
|
+
puts "=> Creating database '#{database}'"
|
88
|
+
|
89
|
+
case config[:adapter]
|
90
|
+
when 'postgres'
|
91
|
+
system("createdb", "-E", charset, "-h", host, "-U", user, database)
|
92
|
+
when 'mysql'
|
93
|
+
query = [
|
94
|
+
"mysql", "--user=#{user}", (password.blank? ? '' : "--password=#{password}"), (%w[127.0.0.1 localhost].include?(host) ? '-e' : "--host=#{host} -e"),
|
95
|
+
"CREATE DATABASE #{database} DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}".inspect
|
96
|
+
]
|
97
|
+
system(query.compact.join(" "))
|
98
|
+
when 'sqlite3'
|
99
|
+
DataMapper.setup(DataMapper.repository.name, config)
|
100
|
+
else
|
101
|
+
raise "Adapter #{config[:adapter]} not supported for creating databases yet."
|
102
|
+
end
|
103
|
+
puts "<= #{t.name} done"
|
104
|
+
end
|
105
|
+
|
106
|
+
desc "Drop the database"
|
107
|
+
task :drop, [:repository] => :environment do |t, args|
|
108
|
+
repo = args[:repository] || ENV['REPOSITORY'] || :default
|
109
|
+
config = DataMapper.repository(repo).adapter.options.symbolize_keys
|
110
|
+
user, password, host = config[:user], config[:password], config[:host]
|
111
|
+
database = config[:database] || config[:path].sub(/\//, "")
|
112
|
+
puts "=> Dropping database '#{database}'"
|
113
|
+
case config[:adapter]
|
114
|
+
when 'postgres'
|
115
|
+
system("dropdb", "-h", host, "-U", user, database)
|
116
|
+
when 'mysql'
|
117
|
+
query = [
|
118
|
+
"mysql", "--user=#{user}", (password.blank? ? '' : "--password=#{password}"), (%w[127.0.0.1 localhost].include?(host) ? '-e' : "--host=#{host} -e"),
|
119
|
+
"DROP DATABASE IF EXISTS #{database}".inspect
|
120
|
+
]
|
121
|
+
system(query.compact.join(" "))
|
122
|
+
when 'sqlite3'
|
123
|
+
File.delete(config[:path]) if File.exist?(config[:path])
|
124
|
+
else
|
125
|
+
raise "Adapter #{config[:adapter]} not supported for dropping databases yet."
|
126
|
+
end
|
127
|
+
puts "<= #{t.name} done"
|
128
|
+
end
|
129
|
+
|
130
|
+
desc 'Load the seed data from db/seeds.rb'
|
131
|
+
task :seed => :environment do |t, _|
|
132
|
+
puts "=> Loading seed data"
|
133
|
+
seed_file = File.expand_path('db/seeds.rb', File.dirname(__FILE__))
|
134
|
+
load(seed_file) if File.exist?(seed_file)
|
135
|
+
puts "<= #{t.name} done"
|
136
|
+
end
|
137
|
+
|
138
|
+
desc "Drop the database, migrate from scratch and initialize with the seed data"
|
139
|
+
task :reset => [:drop, :setup]
|
140
|
+
|
141
|
+
desc "Create the database, migrate and initialize with the seed data"
|
142
|
+
task :setup => [:create, :migrate, :seed]
|
143
|
+
|
144
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'dm-migrations/migration_runner'
|
2
|
+
|
3
|
+
DataMapper.setup(:default, "sqlite3::memory")
|
4
|
+
|
5
|
+
DataMapper::Logger.new(STDOUT, :debug)
|
6
|
+
DataMapper.logger.debug( "Starting Migration" )
|
7
|
+
|
8
|
+
migration 1, :create_people_table do
|
9
|
+
up do
|
10
|
+
create_table :people do
|
11
|
+
column :id, Integer, :serial => true
|
12
|
+
column :name, String, :size => 50
|
13
|
+
column :age, Integer
|
14
|
+
end
|
15
|
+
end
|
16
|
+
down do
|
17
|
+
drop_table :people
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
migration 2, :add_dob_to_people do
|
22
|
+
up do
|
23
|
+
modify_table :people do
|
24
|
+
add_column :dob, DateTime, :allow_nil => true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
down do
|
29
|
+
modify_table :people do
|
30
|
+
drop_column :dob
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# migrate_down!
|
36
|
+
# migrate_up!
|
37
|
+
#
|
38
|
+
# class Person
|
39
|
+
# include DataMapper::Resource
|
40
|
+
#
|
41
|
+
# property :id, Serial
|
42
|
+
# property :name, String, :size => 50
|
43
|
+
# property :age, Integer
|
44
|
+
# property :dob, DateTime, :default => proc { Time.now }
|
45
|
+
#
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# Person.create(:name => "Mark Bates", :age => 31)
|
49
|
+
# puts Person.first.inspect
|
50
|
+
# puts Person.all.inspect
|
51
|
+
|
52
|
+
if $0 == __FILE__
|
53
|
+
if $*.first == "down"
|
54
|
+
migrate_down!
|
55
|
+
else
|
56
|
+
migrate_up!
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
dir = Pathname(__FILE__).dirname.expand_path
|
4
|
+
|
5
|
+
require dir + 'sample_migration'
|
6
|
+
require dir + '../lib/spec/example/migration_example_group'
|
7
|
+
|
8
|
+
describe :create_people_table, :type => :migration do
|
9
|
+
|
10
|
+
before do
|
11
|
+
run_migration
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should create a people table' do
|
15
|
+
repository(:default).should have_table(:people)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have an id column as the primary key' do
|
19
|
+
table(:people).should have_column(:id)
|
20
|
+
table(:people).column(:id).type.should == 'integer'
|
21
|
+
#table(:people).column(:id).should be_primary_key
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have a name column as a string' do
|
25
|
+
table(:people).should have_column(:name)
|
26
|
+
table(:people).column(:name).type.should == 'character varying'
|
27
|
+
table(:people).column(:name).should permit_null
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should have a nullable age column as a int' do
|
31
|
+
table(:people).should have_column(:age)
|
32
|
+
table(:people).column(:age).type.should == 'integer'
|
33
|
+
table(:people).column(:age).should permit_null
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe :add_dob_to_people, :type => :migration do
|
39
|
+
|
40
|
+
before do
|
41
|
+
run_migration
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should add a dob column as a timestamp' do
|
45
|
+
table(:people).should have_column(:dob)
|
46
|
+
table(:people).column(:dob).type.should == 'timestamp without time zone'
|
47
|
+
table(:people).column(:dob).should permit_null
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'dm-migrations'
|