Welcome Guest, Not a member yet? Register   Sign In
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


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



Theme © iAndrew 2016 - Forum software by © MyBB