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

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.

Messages In This Thread
Namespace Migrations Ordering - by MGatner - 04-17-2019, 10:34 AM
RE: Namespace Migrations Ordering - by kilishan - 04-17-2019, 10:39 AM
RE: Namespace Migrations Ordering - by MGatner - 04-17-2019, 10:42 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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