Rails:使用pgloader将sqlite文件转换为postgres db时缺少索引

时间:2016-08-06 11:28:01

标签: ruby-on-rails postgresql sqlite pgloader

对于我的rails应用程序,我正在使用pgloader将本地sqlite3文件转换为postgres数据库。

为此,我创建了一个postgres数据库

 createdb my_database_development

我创建了一个pgload命令文件

load database  
     from 'db/production.sqlite3'  
     into postgresql:///my_database_development  

 with include drop, create tables, create indexes, reset sequences  

  set work_mem to '16MB', maintenance_work_mem to '512 MB';

现在将sqlite文件加载到postgres db中,我觉得我没有任何错误。所有表和记录都被复制,但是当我查看我的rails应用程序时,没有任何记录具有索引(或id)。 以下是将sqlite文件加载到数据库中的输出

simon (master *) Blog-database $ pgloader db/development.sqlite3 postgresql:///my_database_development
2016-08-06T13:57:41.201000+03:00 LOG Main logs in '/tmp/pgloader/pgloader.log'
2016-08-06T13:57:41.222000+03:00 LOG Data errors in '/tmp/pgloader/'
2016-08-06T13:57:41.425000+03:00 WARNING Postgres warning: table "schema_migrations" does not exist, skipping
2016-08-06T13:57:41.626000+03:00 WARNING Postgres warning: table "comments" does not exist, skipping
2016-08-06T13:57:41.627000+03:00 WARNING Postgres warning: table "users" does not exist, skipping
2016-08-06T13:57:41.627000+03:00 WARNING Postgres warning: table "pictures" does not exist, skipping
2016-08-06T13:57:41.828000+03:00 WARNING Postgres warning: table "posts" does not exist, skipping
            table name       read   imported     errors            time
----------------------  ---------  ---------  ---------  --------------
                 fetch          0          0          0          0.001s
       fetch meta data          8          8          0          0.050s
      create, truncate          0          0          0          0.343s
----------------------  ---------  ---------  ---------  --------------
     schema_migrations         12         12          0          0.068s
              comments         23         23          0          0.014s
                 users          3          3          0          0.064s
              pictures         24         24          0          0.069s
                 posts          4          4          0          0.055s
index build completion          0          0          0          0.014s
----------------------  ---------  ---------  ---------  --------------
        Create Indexes          4          4          0          0.312s
       Reset Sequences          0          0          0          0.064s
----------------------  ---------  ---------  ---------  --------------
  Total streaming time         66         66          0          0.742s

pgloader日志看起来像这样

simon pgloader $ cat pgloader.log
2016-08-06T14:23:53.146000+03:00 NOTICE Starting pgloader, log system is ready.
2016-08-06T14:23:53.223000+03:00 LOG Main logs in 'NIL'
2016-08-06T14:23:53.241000+03:00 LOG Data errors in '/tmp/pgloader/'
2016-08-06T14:23:53.241000+03:00 LOG Parsing commands from file #P"/home/simon/Blog-database/sqlite.loader"
2016-08-06T14:23:53.442000+03:00 NOTICE DROP then CREATE TABLES
2016-08-06T14:23:53.443000+03:00 WARNING Postgres warning: table "schema_migrations" does not exist, skipping
2016-08-06T14:23:53.644000+03:00 WARNING Postgres warning: table "comments" does not exist, skipping
2016-08-06T14:23:53.644000+03:00 WARNING Postgres warning: table "users" does not exist, skipping
2016-08-06T14:23:53.645000+03:00 WARNING Postgres warning: table "pictures" does not exist, skipping
2016-08-06T14:23:53.645000+03:00 WARNING Postgres warning: table "posts" does not exist, skipping
2016-08-06T14:23:53.845000+03:00 NOTICE COPY schema_migrations
2016-08-06T14:23:53.846000+03:00 NOTICE CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2016-08-06T14:23:53.846000+03:00 NOTICE COPY comments
2016-08-06T14:23:53.847000+03:00 NOTICE CREATE INDEX "index_comments_on_post_id" ON "comments" ("post_id")
2016-08-06T14:23:53.847000+03:00 NOTICE COPY users
2016-08-06T14:23:53.847000+03:00 NOTICE CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
2016-08-06T14:23:53.847000+03:00 NOTICE CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")
2016-08-06T14:23:53.848000+03:00 NOTICE COPY pictures
2016-08-06T14:23:53.848000+03:00 NOTICE COPY posts
2016-08-06T14:23:54.049000+03:00 NOTICE Reset sequences

这是铁轨问题吗?难道你不能只复制一个id,因为它的行为是受保护的属性吗?

0 个答案:

没有答案