Closed rafaelbreno closed 3 years ago
This code would already work to a point. There IS a primary method but it currently forces auto increment. Might be worth starting there.
I looked into the code and I noticed that there is a method autoIncrement
in Feast\Database\Table
, which creates a new column and sets it as primary key, but as @jpresutti mentioned, it forces auto increment. I think that adding the ability to create the primary key separately is good, however, I'm not sure if the solution suggested by @rafaelbreno will work. That's because every method for creating columns of Feast\Database\Table
returns current instance of a class and I think that it would require a lot of work to add a possibility to "chain" primary
method to a column method.
Instead, I suggest to create primary
method in Table
class just like any other method there. It could look something like this: $table->primary('id');
primary
method would accept one argument - the column name. Of course, this method would need to check if the provided column exists and if primary key hasn't been set before.
What do you think about it?
I am 100% in favor of this idea. I would say that the current autoIncrement
method also needs to be modified to call this new primary
method as well automatically.
@rafaelbreno or @ArrMeeR do either of you want to try your hand at this? If not, I'll probably get to it this weekend.
@jpresutti I will willingly try to implement it tomorrow :)
Now you have something like:
But I think we could modify each column separately, like:
If there's anything that you think that could be done different, let me know. I could start developing just the base for it.