MailingList


Re: Problems with setup Globalize and Postgresql database

by daniel wiesmann :: Rate this Message:

Reply to Author | View in Thread

I have been running globalize 1.1 with rails 1.1.6 on postgres without a
problem for a while now.

I was just looking into upgrading to rails 1.2.3, and came across these
posts.

Installing globalize with postgres does work, at least for me.
I tried to duplicate your issues,  both with the 'rake globalize:setup'
and with the migration.
It worked for me both times. Those results are further below.

There are some important problems with it, however.
I see some attempts in the data.rake task to deal with postgres
correctly, but it fails.
I don't know MySql, but in Postgres sequences are separate things. The
rake script inserts data
into the tables *specifying* the id of the row, instead of allowing
Postgres to generate it.

Thus, after loading the data, the sequences are still at 1. You can see
this by looking at them throught sql
 (do a \ds on psql prompt to see which ones they are).


globalize_1_2_development=> select * from globalize_countries_id_seq;
       sequence_name        | last_value | increment_by |      
max_value      | min_value | cache_value | log_cnt | is_cycled | is_called
----------------------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
 globalize_countries_id_seq |          1 |            1 |
9223372036854775807 |         1 |           1 |       0 | f         | t
(1 row)

This is a problem if you try to insert more data into any of these
tables. The next insert would generate an ID of 1,
which is already taken.

In order to get those IDs right you can do two things:
either do not insert the ID in the SQL, or update the sequences after
the inserts are done.

I tried the first, doing both
  columns.delete_at(0)
  row.delete_at(0)
in the data.rake, load_from_csv (lines 19,27).


Ok, about the install:

This is with postgres 8.2.4, plus rails 1.2.3 on a mac.


 %  rails globalize_1_2 -d postgresql
 %  createdb -U postgres -O username something_development
 %  cd globalize_1_2/
 %  emacs config/database.yml # make sure the right dbs are there.
 % ruby script/plugin install
http://svn.globalize-rails.org/svn/globalize/branches/for-1.2
 %  rake globalize:setup

NOTICE:  CREATE TABLE will create implicit sequence
"globalize_countries_id_seq" for serial column "globalize_countries.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"globalize_countries_pkey" for table "globalize_countries"
NOTICE:  CREATE TABLE will create implicit sequence
"globalize_translations_id_seq" for serial column
"globalize_translations.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"globalize_translations_pkey" for table "globalize_translations"
NOTICE:  CREATE TABLE will create implicit sequence
"globalize_languages_id_seq" for serial column "globalize_languages.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"globalize_languages_pkey" for table "globalize_languages"

Trying it the other way:


%  dropdb -U postgres globalize_1_2_development
DROP DATABASE
% createdb -U postgres -O bakongo globalize_1_2_development
CREATE DATABASE
% ./script/generate globalize
      create  db/migrate
      exists  db/migrate
      create  db/migrate/001_globalize_migration.rb
% rake --trace db:migrate
(in /.../globalize_1_2)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== GlobalizeMigration: migrating
==============================================
-- create_table(:globalize_countries, {:force=>true})
NOTICE:  CREATE TABLE will create implicit sequence
"globalize_countries_id_seq" for serial column "globalize_countries.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"globalize_countries_pkey" for table "globalize_countries"
   -> 0.0097s
-- add_index(:globalize_countries, :code)
   -> 0.0042s
-- create_table(:globalize_translations, {:force=>true})
NOTICE:  CREATE TABLE will create implicit sequence
"globalize_translations_id_seq" for serial column
"globalize_translations.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"globalize_translations_pkey" for table "globalize_translations"
   -> 0.0119s
-- add_index(:globalize_translations, [:tr_key, :language_id])
   -> 0.0039s
-- add_index(:globalize_translations, [:table_name, :item_id,
:language_id],
{:name=>"globalize_translations_table_name_and_item_and_language"})
   -> 0.0067s
-- create_table(:globalize_languages, {:force=>true})
NOTICE:  CREATE TABLE will create implicit sequence
"globalize_languages_id_seq" for serial column "globalize_languages.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"globalize_languages_pkey" for table "globalize_languages"
   -> 0.0110s
-- add_index(:globalize_languages, :iso_639_1)
   -> 0.0036s
-- add_index(:globalize_languages, :iso_639_2)
   -> 0.0033s
-- add_index(:globalize_languages, :iso_639_3)
   -> 0.0030s
-- add_index(:globalize_languages, :rfc_3066)
   -> 0.0032s
== GlobalizeMigration: migrated (60.1271s)
====================================

** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump


Daniel



Joshua Sierles wrote:

>
> On Jul 11, 2007, at 5:20 PM, James B. Byrne wrote:
>>
>> Is this product simply MySQL specific at the moment and just cannot be
>> used with PostgreSQL?
>>
>
> AFAIK none of the active developers are using postgres. If you could
> look into a fix, that would be great!
>
> Joshua
>

 « Return to Thread: Problems with setup Globalize and Postgresql database