Does Laravel support the use of table prefixes? I.e. if I set a prefix in the .env, the migrations will prepend the prefix to the table?
So if my prefix was abc_ and I referred to a table as products in the code (eg. Schema::create('products', function (Blueprint $table) {...) it would actually refer to abc_products?
Thanks for the info. It would be useful if config/database.php was already set to 'prefix' => env('DB_TABLE_PREFIX') so that one need only change the .env file on first installation
@deringer what's the reason for that? Is it a good idea or not in general to use prefixes with laravel?
@jekinney is it slower to refer to the env file?
Any case to ensure every deploy or use of your apps code something like table prefix should be hard coded. What if you swap servers and forget. As the env is not in source control, be easy to forget. It's not a security issue as like db login info that's different per server anyways.
You can make the prefix whatever you want it to be, but it's shouldn't change between instances of your application. Ideally, your application's tables belong in a single database. If you're mixing multiple applications into a single database, I'd advise against that.