Project

General

Profile

Actions

Defect #65

closed

Database inconsistency

Added by bajs bajs almost 17 years ago. Updated almost 17 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

If the user registration fails for some reason (in my case because I created a lang/sv.yml but not the other translation
files needed) the user is only partially created. (I also got an error message)

When retrying (having removed lang/sv.yml) the user registration failed because both the username and the email address
were already in use, but the user did not show up in the user table in the admin interface.

Creating a user should be done atomically inside a transaction in order to fix this.

I repaired my database by manually deleting all references to the user from the database.

I realize that I screwed it up myself, but having foreign key constraints and using transactions really improves the
reliability of data stored in a database.

This with redmine 0.5.0 with a postgresql backend.

Actions #1

Updated by Jean-Philippe Lang almost 17 years ago

Hi,
I guess you got an error because register_sv.rhtml was missing.
But your database wasn't inconsistent. If you had selected
"Status: all" on users/list, you should have seen the
newly registered user.

Concerning translations, I've changed things a bit. Now (in current
source available in trunk), default templates (english)
are automatically used if translated ones are missing.

I agree with you about foreign key constraints, but:
- they're not natively supported by rails
- they're unusable when working with polymorphic associations.

Actions #2

Updated by bajs bajs almost 17 years ago

Ah, I completely missed that dropbox. Thanks.

Too bad about transactions. But shouldn't the database use
foreign keys constraints?

Actions #3

Updated by Jean-Philippe Lang almost 17 years ago

Too bad about transactions.

Transactions are OK. For example, user creation is done inside
a transaction.

But shouldn't the database use foreign keys constraints?

As I said:
- they're not natively supported by rails
- they're unusable when working with polymorphic associations.

Actions #4

Updated by bajs bajs almost 17 years ago

Ooops. I misread.

Can't foreign key constraints be implemented by just
modifying the database?

Example with PostgreSQL:
ALTER TABLE issues ADD CONSTRAINT
issues_project_id_contraint FOREIGN KEY (project_id)
REFERENCES projects (id) MATCH FULL;

Actions #5

Updated by Jean-Philippe Lang almost 17 years ago

Migrations have to be database independent.
There's a rails plugin for managing constraints, but I prefer
to keep migrations independent from any plugin.

Actions

Also available in: Atom PDF