ruby on rails - How to turn a sqlite3 table to a postgresql table? -
i started project rails without knowing heroku required postgresql. convert sqlite3 table postgresql table. how can it?
i found way sql inserts :
begin transaction; insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('0', 'bac à papier', null, 'bac de recyclage', '13309980782012-03-06 03:57:21.219233', '13309980782012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('1', 'bac pvm', 'plastique/verre/métal', null, '13310076572012-03-06 03:57:21.219233', '13310076572012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('2', 'bac de déchets', null, 'poubelle', '13310076572012-03-06 03:57:21.219233', '13310076572012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('3', 'cafétéria', '', '', '2012-03-06 03:57:21.219233', '2012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('4', 'compost', null, null, '2012-03-06 03:57:21.219233', '2012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('5', 'consigne', null, null, '2012-03-06 03:57:21.219233', '2012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('6', 'crd', null, null, '2012-03-06 03:57:21.219233', '2012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('7', 'ressources matérielles', null, null, '2012-03-06 03:57:21.219233', '2012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('8', 'sécurité', null, null, '2012-03-06 03:57:21.219233', '2012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('10', 'technicien chimie', null, null, '2012-03-06 03:57:21.219233', '2012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('11', 'technicien biologie', null, null, '2012-03-06 03:57:21.219233', '2012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('12', 'service informatique', null, null, '2012-03-06 03:57:21.219233', '2012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('13', 'îlot multi-récupération', 'face au b-227', null, '2012-03-06 03:57:21.219233', '2012-03-06 03:57:21.219233'); insert places ("id", "name", "content", "tags", "created_at", "updated_at") values ('14', 'récupérateurs extérieurs', null, null, '2012-03-06 03:57:21.219233', '2012-03-06 03:57:21.219233'); commit;
solution here how solved problem :
i used chris's solution tell rails want use postgresql. then, ran db:migrate
.
to convert sqlite tables postgresql tables, used sliteman, linux program manage sqlite databases. utility, able convert tables sql inserts. logged in postgresql , applied inserts.
voila!
if want local db run on postgres match heroku, change database.yml this:
development: adapter: postgresql encoding: utf8 database: development pool: 5 username: postgres password: test: &test adapter: postgresql encoding: utf8 database: test pool: 5 username: postgres password: production: adapter: postgresql encoding: utf8 database: production pool: 5 username: postgres password: cucumber: <<: *test
this under assumption have postgres role name 'postgres'. if on mac, username should default whatever user shortname is.
Comments
Post a Comment