-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Track IDs for fixtures #2959
Comments
@pdobrigkeit Can you give an example? A simple solution I can think of is using UUID columns so that you can generate and save them yourself and then the default will be auto-generated. |
Yeah, I have a test table with two columns, id and test, id is UUID and default gen_random_uuid() If I run the following SQL to enter fixtures I would either use:
Then I would get the following migrations:
That makes it rather difficult if there would be relationships to the test table because then the uuid would be different between the test system and the live system. The wish would be that in the migration |
Why don't you use an actual UUID in the test column if you need to refer to it later? |
That’s what we are doing now, but you need an external UUID generator and it is a lot of copy and paste if you have lots of rows. But I’ll try to figure out a workflow. |
I'd like to understand the use case here to see if we can do anything to make the experience better. Are you trying to create some sample data and run some tests on it? |
I'll try to explain. The App we are building is a survey tool. So our database contains lots of questions, these questions have references to different tables which store which selections are offered as answers (foreign_key), also the weighting of those different anwers used in the evaluation. So our use-case is that we INSERT those questions and of course we would write regular SQL. If we would have to pre-generate the UUIDs (we have a couple hundred questions), we could add that to our data which is in Excel right now, but then we need an outside tool to generate those UUIDs paste those into the Excel, generate the SQL containing the INSERTS. Example: That is only one part of the database which contains fixture data which we provide as initial data and has to be consistend across development and live systems. Of course I need to copy those values then for the relationships, but that might be easier directly from the migration file? Writing this down I guess I could optimze our process, but in my prior projects I always had the generated ID directly in the migration file and that was quite convinient because the ORM I was using added the relationships directly with the correct IDs and I only had to copy the code for those, now I have to manually edit my relationship queries as well. |
When adding data to tables is there a way to track IDs that are auto-generated? Currently we have to manually add those back into the migration files to be consistent across foreign relations.
The text was updated successfully, but these errors were encountered: