• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Namespace Migrations Ordering

#1
TLDR: Should migrations run in order across all namespaces?

I'm working on user authentication, and a common problem is how to setup a users table that has the necessary fields and structure for authentication but doesn't result in duplicated data. I imagine the three approaches one could take:
1. Create a comprehensive user table, with common fields beyond those require for auth (phone, avatar, fav color, etc)
2. Create an authentication-specific table (`auth_accounts`) and let devs make their own users table to link to it
3. Create a bare-minimum `users` table and let devs add to the table as needed

With CI4's migration controls, #3 seems to me the best practice approach. However I'm running into the issue that namespace migrations are handled namespace-by-namespace (https://github.com/codeigniter4/CodeIgni...r.php#L345) with the following priority: App, PSR4, Classmap, Composer. This is fine for a slow build where the dev includes the authentication library, runs the migrations, then writes her own migration to modify the new `users` table and runs migrations again - but it will fail on deployments.

Considering the above scenario then pushed to a new container: all migrations files are detected at once, the dev's modification migration gets priority and fails because the `users` table doesn't exist yet. The simplest solution (logically, not implementation wise) is to have migrations run in order regardless of their namespace.
Reply

#2
That's a great point. I think for timestamp-based migrations it's definitely best to lump all of them together and run at once. That breaks down when you're doing incremental migrations (001_, 002_, etc). Though that might make a case for getting rid of incremental migrations altogether before the first release. Hmm...
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
Reply

#3
I wouldn't be sad to see incrementals go, as they provide the same exact function just with less information. Maybe I'll start a poll to see if anyone uses them (or would).
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.