Ask Your Question
1

Problem adding Askbot to existing project

asked 2012-01-17 05:03:07 -0600

Olle gravatar image

Hi!

I'm trying to add Askbot to an existing project and have merged settings.py and urls.py from setup_templates into my own settings.py and urls.py. But when I'm migrating askbot (python manage.py migrate askbot) I get the following error:

> askbot:0006_add_subscription_setting_for_comments_and_mentions

**************
Adding subscription on comment responses and name mentions for each user. 
frequency will be automatically set to the most frequent selection 
that user made for any other types of subscriptions

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/south/management/commands/migrate.py", line 105, in handle
    ignore_ghosts = ignore_ghosts,
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/south/migration/__init__.py", line 191, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/south/migration/migrators.py", line 221, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/south/migration/migrators.py", line 292, in migrate_many
    result = self.migrate(migration, database)
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/south/migration/migrators.py", line 125, in migrate
    result = self.run(migration)
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/south/migration/migrators.py", line 99, in run
    return self.run_migration(migration)
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/south/migration/migrators.py", line 81, in run_migration
    migration_function()
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/south/migration/migrators.py", line 57, in <lambda>
    return (lambda: direction(orm))
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/askbot/migrations/0006_add_subscription_setting_for_comments_and_mentions.py", line 26, in forwards
    for user in orm['auth.User'].objects.all():
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/django/db/models/query.py", line 107, in _result_iter
    self._fill_cache()
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/django/db/models/query.py", line 772, in _fill_cache
    self._result_cache.append(self._iter.next())
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/django/db/models/query.py", line 273, in iterator
    for row in compiler.results_iter():
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 680, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/Users/olle/Developer/virtualenvs/archileaks/lib/python2.7/site-packages/django/db/models/sql ...
(more)
edit retag flag offensive close merge delete

Comments

Forgot to add that the existing project have users.

Olle gravatar imageOlle ( 2012-01-17 06:34:40 -0600 )edit

5 Answers

Sort by ยป oldest newest most voted
1

answered 2012-08-22 11:51:07 -0600

dajafa gravatar image

A easy fix is to change 0001_initial to define those 5 fields as "null=True".

edit flag offensive delete link more
1

answered 2012-08-13 07:46:27 -0600

NickJ gravatar image

I had the same problem. Executing the following before running ./manage.py migrate askbot fixed the silent fails for the rest to commit:

ALTER TABLE "auth_user"
ADD COLUMN "website" varchar(200) NOT NULL DEFAULT '',
ADD COLUMN "location" varchar(100) NOT NULL DEFAULT '',
ADD COLUMN "about" text NOT NULL DEFAULT '',
ADD COLUMN "real_name" varchar(100) NOT NULL DEFAULT '', 
ADD COLUMN "gravatar" varchar(32) NOT NULL DEFAULT '';
edit flag offensive delete link more

Comments

Do you have any of these fields in auth_user?

Evgeny gravatar imageEvgeny ( 2012-08-13 08:01:56 -0600 )edit

@Evgeny I only needed to add these 5 columns manually and then the rest of the migration worked, adding all the other new ones needed.

NickJ gravatar imageNickJ ( 2012-08-13 09:06:24 -0600 )edit

@NickJ, I've made the change suggested by @dajafa to the first migration. Could you test it on your system?

Evgeny gravatar imageEvgeny ( 2012-08-25 19:37:55 -0600 )edit
0

answered 2012-01-17 08:25:21 -0600

Evgeny gravatar image

updated 2012-01-17 08:40:01 -0600

Olle, it seems that first migration of askbot possibly did not work.

Type python manage.py migrate --list - what do you see?

Also you could log in to the database and see what the table auth_user looks like.

In your case I'd start over and try running just migration 1 with command:

python manage.py migrate askbot 0001

Inspect the output and the database structure after the migration, if you find errors, we'll try to fix them.

edit flag offensive delete link more
0

answered 2012-01-18 04:05:58 -0600

Olle gravatar image

I restored my database (PostgreSQL) and started over with "python manage.py migrate askbot 0001". This is the output:

relation "askbot_badgedata" does not exist
LINE 1: ..."."slug", "askbot_badgedata"."awarded_count" FROM "askbot_ba...
                                                             ^
 - Soft matched migration 0001 to 0001_initial.
Running migrations for askbot:
 - Migrating forwards to 0001_initial.
 > askbot:0001_initial

I didn't notice the badge_data error before.

This is what auth_users looks like before migration 0001:

id serial NOT NULL,
  username character varying(30) NOT NULL,
  first_name character varying(30) NOT NULL,
  last_name character varying(30) NOT NULL,
  email character varying(75) NOT NULL,
  password character varying(128) NOT NULL,
  is_staff boolean NOT NULL,
  is_active boolean NOT NULL,
  is_superuser boolean NOT NULL,
  last_login timestamp with time zone NOT NULL,
  date_joined timestamp with time zone NOT NULL,
  CONSTRAINT auth_user_pkey PRIMARY KEY (id ),
  CONSTRAINT auth_user_username_key UNIQUE (username )

And this is how auth_users looks like after migration 0001:

  id serial NOT NULL,
  username character varying(30) NOT NULL,
  first_name character varying(30) NOT NULL,
  last_name character varying(30) NOT NULL,
  email character varying(75) NOT NULL,
  password character varying(128) NOT NULL,
  is_staff boolean NOT NULL,
  is_active boolean NOT NULL,
  is_superuser boolean NOT NULL,
  last_login timestamp with time zone NOT NULL,
  date_joined timestamp with time zone NOT NULL,
  hide_ignored_questions boolean NOT NULL,
  gold smallint NOT NULL,
  email_isvalid boolean NOT NULL,
  email_key character varying(32),
  date_of_birth date,
  reputation integer NOT NULL,
  bronze smallint NOT NULL,
  tag_filter_setting character varying(16) NOT NULL,
  last_seen timestamp with time zone NOT NULL,
  silver smallint NOT NULL,
  questions_per_page smallint NOT NULL,
  response_count integer NOT NULL,
  CONSTRAINT auth_user_pkey PRIMARY KEY (id ),
  CONSTRAINT auth_user_username_key UNIQUE (username ),
  CONSTRAINT auth_user_reputation_check CHECK (reputation >= 0)
edit flag offensive delete link more

Comments

Olle, I don't understand this error, can you email me at evgeny.fadeev@gmail.com ? The migration 1 is not referring to the badgedata table. Possibly your database was not in the true original state when you started the process the second time. It seems as if the migration 1 did not finish.

Evgeny gravatar imageEvgeny ( 2012-01-19 12:08:17 -0600 )edit
0

answered 2012-03-19 20:32:12 -0600

ShlomoZippel gravatar image

updated 2012-03-19 22:28:39 -0600

I am encountering the same issue. My setup also failed at migration 0006. Here is what my auth_user looks like after migration 0005:

                                          Table "public.auth_user"
         Column         |           Type           |                       Modifiers
------------------------+--------------------------+--------------------------------------------------------
 id                     | integer                  | not null default nextval('auth_user_id_seq'::regclass)
 username               | character varying(30)    | not null
 first_name             | character varying(30)    | not null
 last_name              | character varying(30)    | not null
 email                  | character varying(75)    | not null
 password               | character varying(128)   | not null
 is_staff               | boolean                  | not null
 is_active              | boolean                  | not null
 is_superuser           | boolean                  | not null
 last_login             | timestamp with time zone | not null
 date_joined            | timestamp with time zone | not null
 hide_ignored_questions | boolean                  | not null
 gold                   | smallint                 | not null
 email_isvalid          | boolean                  | not null
 email_key              | character varying(32)    |
 date_of_birth          | date                     |
 reputation             | integer                  | not null
 bronze                 | smallint                 | not null
 tag_filter_setting     | character varying(16)    | not null
 last_seen              | timestamp with time zone | not null
 silver                 | smallint                 | not null
 questions_per_page     | smallint                 | not null
 response_count         | integer                  | not null

So, quite a few fields missing (website, about, gravatar)

I took a look at the initial migration - I guess safe_add_column failed silently and continued to the next column.

Edit: I got it to work after manually adding missing columns. I had to add about 7-8 of them each time 'migrate' reached an error. Also had to drop a few tables that were being added multiple times. Isn't this exactly what south is supposed to prevent? Weird.

btw I'm using Django 1.3.1 and PostgreSQL 8.4.11 and integration with an existing project, existing users, and existing auth system (django-allauth).

edit flag offensive delete link more

Comments

Thanks for the info, what you could do - set logging level in the database to maximum and look into the log file, hopefully that will tell what errors there are. The safe_add_column may have issues, it's used only in the 0001 migration.

Evgeny gravatar imageEvgeny ( 2012-03-20 09:34:03 -0600 )edit

Now looking at that function - yes it might hide the errors - you can try removing the try/except statement and hopefully you will see errors in the console.

Evgeny gravatar imageEvgeny ( 2012-03-20 09:36:12 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-01-17 05:03:07 -0600

Seen: 1,313 times

Last updated: Aug 22 '12