mishamx / yii-user

Yii PHP Framework extension for registration and management users accounts.
http://yii-user.2mx.org/
186 stars 154 forks source link

When deleting ProfileField, tbl_profiles primary key is dropped. #24

Open kachar opened 11 years ago

kachar commented 11 years ago

How to reproduce:

  1. Use sqlite database
  2. Create a new profile field
  3. Delete the profile field

What do we see on User module homepage:

Error triggered by CActiveFinder::populateRecord() at line 784:

...
foreach($this->_pkAlias as $name=>$alias)
...

The cause of the error is that Yii does not support database tables with no primary key and when we delete a profile field the table is re-created without primary key.

Here is an issue on the topic: https://code.google.com/p/yii/issues/detail?id=2922

Before deletion of the profile field the table structure is:

CREATE TABLE tbl_profiles (
  user_id INTEGER NOT NULL PRIMARY KEY,
  lastname varchar(50) NOT NULL DEFAULT '',
  firstname varchar(50) NOT NULL DEFAULT '',
  allow_multi_sessions INTEGER NOT NULL DEFAULT '0'
);

After:

CREATE TABLE tbl_profiles (user_id,lastname,firstname)

Most probably the solution will be to fix ProfileFieldController::actionDelete()