Skip to content

Commit

Permalink
Merge pull request #97 from it3s/migration
Browse files Browse the repository at this point in the history
Migration
  • Loading branch information
LuizArmesto committed Nov 23, 2014
2 parents f7bf5f4 + 4394cd1 commit cf5f3f6
Show file tree
Hide file tree
Showing 10 changed files with 390 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

# uploads
/public/uploads
/public/mootiro_media

# vagrant
.vagrant
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ gem 'differ' # build diffs
gem 'safe_yaml', require: false # safe yaml loading
gem "active_model_serializers", "~> 0.8.0" # model serializer
gem 'public_activity' # record users activity
gem 'connection_pool' # connection pool used for mootiro migration

gem 'better_errors' # better error page, and shell session when crash
gem 'binding_of_caller' # used by better_errors
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ DEPENDENCIES
clean_logger
coffee-rails (~> 4.0.1)
compass-rails
connection_pool
coveralls
database_cleaner
differ
Expand Down
3 changes: 3 additions & 0 deletions app/models/mootiro_oid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class MootiroOID < ActiveRecord::Base
belongs_to :content, polymorphic: true
end
8 changes: 8 additions & 0 deletions db/migrate/20141122002836_create_mootiro_oids.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class CreateMootiroOids < ActiveRecord::Migration
def change
create_table :mootiro_oids do |t|
t.string :oid, index: true
t.references :content, polymorphic: true, index: true
end
end
end
5 changes: 5 additions & 0 deletions db/migrate/20141122232948_add_migrated_info_to_maps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMigratedInfoToMaps < ActiveRecord::Migration
def change
add_column :maps, :migrated_info, :json
end
end
11 changes: 10 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20141030173752) do
ActiveRecord::Schema.define(version: 20141122232948) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -160,11 +160,20 @@
t.datetime "updated_at"
t.integer "administrator_id", null: false
t.json "additional_info"
t.json "migrated_info"
end

add_index "maps", ["administrator_id"], :name => "index_maps_on_administrator_id"
add_index "maps", ["tags"], :name => "index_maps_on_tags"

create_table "mootiro_oids", force: true do |t|
t.string "oid"
t.integer "content_id"
t.string "content_type"
end

add_index "mootiro_oids", ["content_id", "content_type"], :name => "index_mootiro_oids_on_content_id_and_content_type"

create_table "notifications", force: true do |t|
t.integer "user_id", null: false
t.integer "activity_id", null: false
Expand Down
37 changes: 37 additions & 0 deletions docs/mootiro_migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## migrating from mootiro

- run Intermediate redis (set a really long pass)
- set on the server the following env vars:

```
export REDIS_HOST=host
export REDIS_PORT=6379
export REDIS_PASS=really long redis server password
```

- run django shell

```
from migrate.tasks import migrate_all
migrate_all()
```

- on the Meppit server set these env vars

```
export MOOTIRO_REDIS_HOST=host
export MOOTIRO_REDIS_PORT=6379
export MOOTIRO_REDIS_PASS=really long redis server password
```

- copy all media files from Mootiro `media/upload` folder to Meppit `public/mootiro_media`

- run the task

```
rake mootiro_import
```

WARN: sometimes the connection with redis dies, If that happens just run again the task, and it will resume
from where it stoped
Loading

0 comments on commit cf5f3f6

Please sign in to comment.