Comments (6)
@robsontenorio good idea :)
It might be even better to have it in the same method
Field::make('user_id')->unsignedInteger()->references('users.id');
Field::make('user_id')->unsignedInteger()->references('users', 'id');
Field::make('user_id')->unsignedInteger()->references(User::class, 'id');
What about deleting on cascade? Do you use db level deletion or you delete related entities in the app?
from laravel-smart.
I don’t use DB level deletion.
I just suggest the same syntax of Laravel migration just for consistency with well known methods from Laravel.
from laravel-smart.
@deiucanta I think this is a pretty important issue. A must have.
Without this we can't guarantee FK constraints out of box for smart migrations, and would be necessary do it manually editing files (boring).
About syntax i do prefer.
Field::make('user_id')->unsignedInteger()->references('users.id');
I'm not expert on databases. But, on this first version we can consider that FK's will always be unsignedInteger()
type (i have never used other type than this). So, this statement can be suppressed by adding it on "field types" by default when using references()
.
Field::make('user_id')->required()->unsignedInteger()->references('users.id')->label("User");
Field::make('user_id')->required()->references('users.id')->label("User");
Can you handle it?
from laravel-smart.
The issue here might be if the user id is not unsignedInteger
. It can be string
, integer
(with negative values), unsignedBigInteger
, etc. How to handle that?
I created REST APIs in Laravel that used UUIDs for the primary key. I also can imagine someone having big tables and using bigIncrements
instead of increments
.
from laravel-smart.
The diff algorithm is just a proof of concept and I'd rather refactor it than patch it to make foreign keys work. Especially for dropping them.
We also didn't touch the requirement of having indexes on multiple fields. That would also impact the diff algorithm, the migration generation, and even the API for field definition.
I'd say we should address all these issues together to get the best outcome.
from laravel-smart.
from laravel-smart.
Related Issues (19)
- Idea: lookup models HOT 14
- Converting existing model to Smart model HOT 5
- Error: guarded() not working as expected
- Support for User model HOT 4
- What if relations were defined as fields? HOT 7
- Idea: label() HOT 2
- rule customization HOT 4
- Cache `$model->fields()` HOT 2
- Support virtual fields for mysql HOT 4
- Erro: ID validation
- Support field comment
- Idea: timestamps() HOT 1
- [Question] Still active? HOT 2
- not install in laravel 9
- Error: change to nullable() HOT 1
- Improvement: Throw an exception when type is not defined
- Idea: create new fresh smart migration
- Error: Class 'Deiucanta\Smart\Rule' not found
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-smart.