Xethron / migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
3.32k stars 591 forks source link

created_at, updated_at - "CURRENT_TIMESTAMP" & "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" #176

Open niccolofavari opened 5 years ago

niccolofavari commented 5 years ago

Hello! I have these two columns in my tables: created_at updated_at

They're set to default "CURRENT_TIMESTAMP" and "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" respectively. These constraints are ignored by the generator. Is it somehow possible to respect those?

Thank you, Nikles

cacpmw commented 5 years ago

I think laravel will print the current timestamp automatically. At least this is how it has always worked for me.

niccolofavari commented 5 years ago

I see what you mean. My point was the generated migration is losing this constraint. It works flawlessly for foreign keys but I was wondering why this one’s lost.

The resulting DB relies on the laravel app to keep those constraints working. The moment the app layer changes (or the moment someone touches a record manually or via another app) those timestamps are not updated. It’s a pity. I mean everything else works wonderfully.

Anyway as of now I’m updating the generated migrations manually to add the constraints; not a big deal for now :)

On Tue, 4 Dec 2018 at 19:39, Carlos Albuquerque Carneiro < notifications@github.com> wrote:

I think laravel will print the current timestamp automatically. At least this is how it has always worked for me.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Xethron/migrations-generator/issues/176#issuecomment-444209821, or mute the thread https://github.com/notifications/unsubscribe-auth/AALLjUa0i3KnOR86aVvZi4tRWjmd6JCFks5u1sF7gaJpZM4Y7uCA .