7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/active_couch/migrations/migrator.rb', line 7
def migrate(site, migration)
if migration.view.nil? || migration.database.nil?
raise ActiveCouch::MigrationError, "Both the view and the database need to be defined in your migration"
end
conn = Connection.new(site)
response = conn.put("/#{migration.database}/_design/#{migration.view}", migration.view_js)
case response.code
when '201'
true
else
raise ActiveCouch::MigrationError, "Error migrating view - got HTTP response #{response.code}"
end
end
|