Closed mkswati closed 1 year ago
Does this table have a column named 'id' with a data type of UUID?
yes 'id' field is there and it is of type UUID. The following line is creating problem. The following line should only execute if the 'id' field is of integer type.
if (DB::connection()->getSchemaBuilder()->hasColumn($table, 'id')) { $return DB::select("select setval('{$table}_id_seq', max(id)) from {$table}"); }
correct, I agree.
smallint, integer, or bigint types.
ideally it would be able to check if the column is a sequence column type.
I will be able to add the fix in a couple days.
Could you please let me know how to get the type of column. Because I too many seeds to upload but it stuck at this point.
This looks like the likely api: https://laravel.com/api/9.x/Illuminate/Database/Schema/Builder.html#method_getColumnType
I have to dig into it a bit more. Unfortunately it is late here and I have to head to bed now, but I will look at it in the morning.
You could try the API above. Or if you are not using any sequence id's elsewhere, I would recommend commenting out these lines for now as you only need them if you have id columns that are sequence ids.
Thanks for your assistance, for the time being I have commented that line and move ahead. But still there is issue with other sequences as all are starting from 1.
I have pushed a dev version with a fix. To use the development version, update your composer.json per below
"require-dev": {
...
"bfinlay/laravel-excel-seeder": "dev-postgres-sequence",
...
}
I have run this against the current test suite and worked out a bug and it passes.
After I write some more test cases and get the github actions running against the new database containers I will do a release.
Let me know how it works for you.
Issue is fixed in v3.3.0
If I try to import table in postgresql having uuid as primary key it gives error like SQLSTATE[42883]: Undefined function: 7 ERROR: function max(uuid) does not exist LINE 1: select setval('schema.table_id_seq', max(id)) from....