Closed kurim closed 4 years ago
Yes, it should. The sql server is what sorts the rows. What version of MySQL or MariaDB are you using?
I'll see if I can reproduce with a test.
Hi,
it is 10.4.13-MariaDB
This should be a workaround for now, https://github.com/pierobot/mangapie/commit/0214f0a2a327b69657b9b4c4934f8e648ef95ad7
fine, but I got another error...
local.ERROR: Trying to get property 'name' of non-object (View: /resources/views/user/history.blade.php) {"userId":3,"exception":"[object] (ErrorException(code: 0):
Trying to get property 'name' of non-object (View: /resources/views/user/history.blade.php) at /storage/framework/views/01601be8b2b2f797dd91e741c3b2fe4fbb202b34.php:30, ErrorException(code: 0):
Trying to get property 'name' of non-object at /storage/framework/views/01601be8b2b2f797dd91e741c3b2fe4fbb202b34.php:30) [stacktrace]
I'am not sure where it come from may be I delete one chapter which now cannot be found
edit: find the old entries and delete them, to fix it. But I think if you remove a manga or chapter it should cleanup also in history feed, or marked as not available anymore.
Not sure if it cause the remove of the old entries (by hand) or some other reason.
Illuminate\Database\QueryException : SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
mangapie
.#sql-675_1ccb4
, CONSTRAINTreader_histories_user_id_foreign
FOREIGN KEY (user_id
) REFERENCESusers
(id
) ON DELETE CASCADE) (SQL: alter tablereader_histories
add constraintreader_histories_user_id_foreign
foreign key (user_id
) referencesusers
(id
) on delete cascade)
/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
I think that might have been caused by a deleted entry before the migration.
See if this returns anything in php artisan tinker
ReaderHistory::whereDoesntHave('user')->get();
If it does then do
ReaderHistory::whereDoesntHave('user')->forceDelete();
Same problem here. I dit delete an entry with the command, but still can't init mangapie:
Generating app key...
App key already exists. Skipping.
Publishing vendor files...
Config file for Intervention\Image already exists. Skipping.
Vendor pagination blade already exists. Skipping.
Migrating...
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table `mangapie`.`completed` (errno: 121 "Duplicate key on
write or update") (SQL: alter table `completed` add constraint `completed_user_id_foreign` foreign key (`user_id`) references `users` (`id`) on delete
cascade)
at /var/www/mangapie/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[HY000]: General error: 1005 Can't create table `mangapie`.`completed` (errno: 121 "Duplicate key o
n write or update")")
/var/www/mangapie/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:129
2 PDOException::("SQLSTATE[HY000]: General error: 1005 Can't create table `mangapie`.`completed` (errno: 121 "Duplicate key on write or update")")
/var/www/mangapie/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:127
Please use the argument -v to see more details.
My Issue can be solved after I add the deleted entry manualy
But it end in the same error like donotos have
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table `mangapie`.`reader_histories` (errno: 121 "Duplicate key on write or update") (SQL: alter table `reader_histories` add constraint `reader_histories_user_id_foreign` foreign key (`user_id`) references `users` (`id`) on delete cascade)
at /home/kurim/public_html/manga.kurim.de/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
But that the table can't created is logic cause it already exist in database...
Both of you likely had an error after the table was already altered and that's why you can't migrate.
In your mysql client,
@donotos
show keys from completed;
@kurim
show keys from reader_histories;
You're going to need to drop the foreign keys and indexes.
You mean this:
Yes, that's why it's saying there's a duplicate key. It's trying to create it again.
Sorry, It's show keys from reader_histories;
not show all keys from reader_histories;
result is nearly the same
Okay, then you only need to drop that one. In php artisan tinker
Illuminate\Support\Facades\Schema::table('reader_histories', function ($table) {
$table->dropForeign(['user_id']);
});
I just pushed a commit, try to php artisan mangapie:init
again.
no duplicate on my side
MariaDB [mangapie]> show keys from completed;
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+--------
-------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_c
omment |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+--------
-------+
| completed | 0 | PRIMARY | 1 | id | A | 16 | NULL | NULL | | BTREE | |
|
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+--------
-------+
1 row in set (0.000 sec)
@donotos What is the last row you get from select * from migrations
?
i reupdated from my last snapshot. seems that your last commit worked. everything is alright now thanks!
your commit works fine, thx
Hey pierobot,
i think a last read "1 hour ago" should be on top instead of 2 days