-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Incomplete migration using a database schema with existing migration #34281
Comments
I tested this modification in the file laravel/framework/src/Illuminate/Database/Schema/PostgresSchemaState.php :
There may be a better solution but it works. |
It's hard to see what exactly changed. Can you PR your suggested change instead? |
Closing this as a PR is now open. |
I wasn't able to reproduce this issue so don't feel comfortable changing the code at this time. Need more feedback from Pgsql users as to specifically what is happening. |
Hello and thank you. SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create table at D:\wamp64\www\livewire\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671 1 D:\wamp64\www\livewire\vendor\laravel\framework\src\Illuminate\Database\Connection.php:464 2 D:\wamp64\www\livewire\vendor\laravel\framework\src\Illuminate\Database\Connection.php:464 D:\wamp64\www\livewire> |
in the dump schema file you have
but postgress does not update autoincrement id if the autoincrement function is not called so when you try to insert new it tries with id of 1. Looks like https://stackoverflow.com/questions/9108833/postgres-autoincrement-not-updated-on-explicit-id-inserts appending this line temp solves it |
Description:
Incomplete migration using a database schema with existing migration due to a sequence issue.
Steps To Reproduce:
Create "test" project :
laravel new test
Create postgresql database :
createdb test
Migrate :
php artisan migrate
Dump and prune schema :
php artisan schema:dump --prune
Make new migration and run migration :
Create "test2" project :
laravel new test2
Create postgresql database :
createdb test2
Remove default migrations and copy schema directory from test/database to test2/database
Copy test/database/migrations/2020_09_11_064507_add_table_test.php to test2/database/migrations
Run migration :
php artisan migrate
Error :
The text was updated successfully, but these errors were encountered: