Adding option based on SGBD type to fix auto_increment sequence #189
cyrilmanuel
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all,
first of all, thanks you for this incredible package !
I used Iseed since 2 years and all works good !
Today, I was wondering about an optional feature that's can help me and more people!
Let me explain the context :
I use Iseed to retrieve data from my PostgreSQL database and generate some seeds. This project helps me to make the modification in the newest version of my web project when the database structure change. With these seeds, I can change directly the structure to add fields when the migrations of my database was changed.
But, i have to insert for each seed 3 lines depending on the SGBD that i use. these lines are used to change the sequence of increment ID for each table describes in seeds. the seeds return for each entry the ID used and ensure that all connections between tables (FK, PK ) are correct.
But, in my case, if i push the seed with the --refresh flag to generate all the database, the sequence of increment ID was not defined to the max ID value of the current seed.
To do this i need to implement the 3 lines SQL in the end of the iseed generated files.
let me show you an example :
$max = DB::table('batches')->max('id') + 1;
$statement = "ALTER SEQUENCE batches_id_seq RESTART WITH $max";
\DB::unprepared($statement);
This lines work only for an PostgreSQL SGBD but they don't have many change to do to work for every type of BDD.
At this point my Idea is to add, based on the data that deserve the creation of the files, a new flag in the Iseed Command to specify the SGBD to add the correct 3 lines on each files at the end.
It's a suggest, but if you have another idea to do this without having to change my 56 seeds, tell me !
Kind regards,
Cyril
Beta Was this translation helpful? Give feedback.
All reactions