Stream Migration - Add Foreign Key

kiltedup - 8 months ago

When you create a stream via php artisan make:stream, are there any options to add foreign key constraints to the migration that is created? Digging around docs and code and nothing is jumping out at me!

TIA

piterden - 8 months ago

Actually, you could set it after module would be maiden. Inside migrations folder.

You could use for it one of the field_type addon under anomaly namespace (or even custom). Relations could be assign with few of field types by setting of a model class which is EntityModel extender.

Try to look for working examples under the core folder.

ryanthompson - 8 months ago

Stream migrations can still run the up and down methods (which are run after the properties are handled like $stream / $assignments) so you can add them there.

ryanthompson - 8 months ago

I would like to build up a few utilities to make it easier to define these and indexes too. Just haven't quite nailed it down in my head yet.

kiltedup - 8 months ago

Ah - thats good. I added a separate migration with up/down so good to know I can do it in one place.

Getting the foreign constraints in has been a pain though - more to do with what I've been asked to add rather than the code.

But - noticed that relationship IDs are in table with INT (11) whereas Primary ID's are INT (10) .... is that intentional?