diff --git a/mongodb/districts.bson b/mongodb/districts.bson new file mode 100644 index 0000000..c108a97 Binary files /dev/null and b/mongodb/districts.bson differ diff --git a/mongodb/districts.metadata.json b/mongodb/districts.metadata.json new file mode 100644 index 0000000..0f95b6a --- /dev/null +++ b/mongodb/districts.metadata.json @@ -0,0 +1 @@ +{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"wilayah_administratif.districts"}]} \ No newline at end of file diff --git a/mongodb/provinces.bson b/mongodb/provinces.bson new file mode 100644 index 0000000..fb4ff46 Binary files /dev/null and b/mongodb/provinces.bson differ diff --git a/mongodb/provinces.metadata.json b/mongodb/provinces.metadata.json new file mode 100644 index 0000000..b2391c6 --- /dev/null +++ b/mongodb/provinces.metadata.json @@ -0,0 +1 @@ +{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"wilayah_administratif.provinces"}]} \ No newline at end of file diff --git a/mongodb/regencies.bson b/mongodb/regencies.bson new file mode 100644 index 0000000..33e9b19 Binary files /dev/null and b/mongodb/regencies.bson differ diff --git a/mongodb/regencies.metadata.json b/mongodb/regencies.metadata.json new file mode 100644 index 0000000..4dda845 --- /dev/null +++ b/mongodb/regencies.metadata.json @@ -0,0 +1 @@ +{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"wilayah_administratif.regencies"}]} \ No newline at end of file diff --git a/mongodb/system.indexes.bson b/mongodb/system.indexes.bson new file mode 100644 index 0000000..4b0fe67 Binary files /dev/null and b/mongodb/system.indexes.bson differ diff --git a/mongodb/villages.bson b/mongodb/villages.bson new file mode 100644 index 0000000..eb08567 Binary files /dev/null and b/mongodb/villages.bson differ diff --git a/mongodb/villages.metadata.json b/mongodb/villages.metadata.json new file mode 100644 index 0000000..e0b1b66 --- /dev/null +++ b/mongodb/villages.metadata.json @@ -0,0 +1 @@ +{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"wilayah_administratif.villages"}]} \ No newline at end of file diff --git a/scripts/mysql_mongodb_converter/README.md b/scripts/mysql_mongodb_converter/README.md new file mode 100644 index 0000000..fb5dae9 --- /dev/null +++ b/scripts/mysql_mongodb_converter/README.md @@ -0,0 +1,11 @@ +# MySQL to MongoDB conversion +Using Mongify, a ruby based application to convert and translate mysql database to mongodb. +Please check http://mongify.com/getting_started.html + +# Getting started +- Install mongify `gem install mongify` +- Make sure you have import the wilayah-administratif-indonesia dump file (indonesia.mysql) on your running MySQL database +- Make sure you have a running MongoDB +- Check `database.config` and adjust the connection crendentials for both MySQL and MongoDB +- Run `mongify check database.config` to verify the connection +- Run the conversion process `mongify process database.config translation.rb` diff --git a/scripts/mysql_mongodb_converter/database.config b/scripts/mysql_mongodb_converter/database.config new file mode 100644 index 0000000..ebf5888 --- /dev/null +++ b/scripts/mysql_mongodb_converter/database.config @@ -0,0 +1,12 @@ +sql_connection do + adapter "mysql" + host "localhost" + username "root" + password "" + database "wilayah_administratif" +end + +mongodb_connection do + host "localhost" + database "wilayah_administratif" +end diff --git a/scripts/mysql_mongodb_converter/translation.rb b/scripts/mysql_mongodb_converter/translation.rb new file mode 100644 index 0000000..ba3021e --- /dev/null +++ b/scripts/mysql_mongodb_converter/translation.rb @@ -0,0 +1,35 @@ +table "districts" do + column "id", :key, :as => :integer, :rename_to => "code" + column "regency_id", :integer, :references => "regencies", :rename_to => "regency" + column "name", :string + + before_save do |row| + row.code = row.delete('pre_mongified_id') + end +end + +table "provinces" do + column "id", :key, :as => :integer + column "name", :string + before_save do |row| + row.code = row.delete('pre_mongified_id') + end +end + +table "regencies" do + column "id", :key, :as => :integer, :rename_to => "code" + column "province_id", :integer, :references => "provinces", :rename_to => "province" + column "name", :string + before_save do |row| + row.code = row.delete('pre_mongified_id') + end +end + +table "villages" do + column "id", :key, :as => :integer, :rename_to => "code" + column "district_id", :integer, :references => "districts", :rename_to => "district" + column "name", :string + before_save do |row| + row.code = row.delete('pre_mongified_id') + end +end