Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to DB Version 11 fails (sqlite) #954

Closed
Weishaupt opened this issue Jun 23, 2017 · 0 comments
Closed

Updating to DB Version 11 fails (sqlite) #954

Weishaupt opened this issue Jun 23, 2017 · 0 comments
Assignees
Labels

Comments

@Weishaupt
Copy link
Contributor

Hey there,
I'm a long time user of selfoss.
Updating to the latest master fails with this error (obviously, I'm using sqlite)

$ php cliupdate.php 
PDOStatement: NOT NULL constraint failed: new_items.updatetime
[daos/sqlite/Database.php:201] DB\SQL->exec()
[daos/Database.php:25] daos\sqlite\Database->__construct()
[daos/Items.php:25] daos\Database->__construct()
[helpers/ContentLoader.php:23] daos\Items->__construct()
[cliupdate.php:6] helpers\ContentLoader->__construct()
an error occured

The problem seem to be some very old entries in my db

sqlite> select count(*) from items
  ...> where updatetime is null;
60
sqlite> select id, datetime from items
   ...> where updatetime is null;
133|2013-03-20 08:30:57
425|2013-03-22 11:20:25
1091|2013-03-27 09:56:46
2026|2013-04-02 14:40:00

I personally fixed it, altering the data in the sqlite table. But I'd suggest altering the update routine.

sqlite> update items set updatetime = datetime
   ...> where updatetime is null;
@Weishaupt Weishaupt changed the title Updating to DB Version 11 fails Updating to DB Version 11 fails (sqlite) Jun 23, 2017
@jtojnar jtojnar added the bug label Jun 23, 2017
@jtojnar jtojnar self-assigned this Jun 23, 2017
jtojnar added a commit that referenced this issue Jun 23, 2017
In 14442c0, `updatetime` field was
introduced to the `items` table. Unfortunately, unlike the
initialization, the migration did not flag the field `NOT NULL`. This
resulted in the pre-existing items to have `updatetime = 0`. When
re-creating the table for adding an another field in
83794f4, the `updatetime` was set to
`NOT NULL`, based on the previous initialization. That caused an error
when migrating those items.

This patch fixes the assumption by setting the `NULL` fields.

Closes: #954
jtojnar added a commit that referenced this issue Jun 23, 2017
In 14442c0, `updatetime` field was
introduced to the `items` table. Unfortunately, unlike the
initialization, the migration did not flag the field `NOT NULL`.
Additionally, the `lastseen` column in MySQL database was added as
`NULL`able in 83794f4. These
inconsistencies can lead to incorrect assumptions and cause bugs like #954.

This patch adds the `NOT NULL` constraint for `updatetime and `lastseen`
fields, making the database consistent again. SQLite consistency was
already rectified in 83794f4 by
re-creating the table.
jtojnar added a commit that referenced this issue Jun 23, 2017
In 14442c0, `updatetime` field was
introduced to the `items` table. Unfortunately, unlike the
initialization, the migration did not flag the field `NOT NULL`. This
resulted in the pre-existing items to have `updatetime = 0`. When
re-creating the table for adding an another field in
83794f4, the `updatetime` was set to
`NOT NULL`, based on the previous initialization. That caused an error
when migrating those items.

This patch fixes the assumption by filling the `NULL` fields.

Closes: #954
jtojnar added a commit that referenced this issue Jun 23, 2017
In 14442c0, `updatetime` field was
introduced to the `items` table. Unfortunately, unlike the
initialization, the migration did not flag the field `NOT NULL`.
Additionally, the `lastseen` column in MySQL database was added as
`NULL`able in 83794f4. These
inconsistencies can lead to incorrect assumptions and cause bugs like #954.

This patch adds the `NOT NULL` constraint for `updatetime` and `lastseen`
fields, making the database consistent again. SQLite consistency was
already rectified in 83794f4 by
re-creating the table.
jtojnar added a commit that referenced this issue Jun 27, 2017
In 14442c0, `updatetime` field was
introduced to the `items` table. Unfortunately, unlike the
initialization, the migration did not flag the field `NOT NULL`.
Additionally, the `lastseen` column in MySQL database was added as
`NULL`able in 83794f4. These
inconsistencies can lead to incorrect assumptions and cause bugs like #954.

This patch adds the `NOT NULL` constraint for `updatetime` and `lastseen`
fields, making the database consistent again. SQLite consistency was
already rectified in 83794f4 by
re-creating the table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants