LinuxDoku / migratordotnet

Automatically exported from code.google.com/p/migratordotnet
0 stars 0 forks source link

Add Timestamps helper #19

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Rip-off from Rails,

table.AddTimeStamps() (or a similar name) to add created_at and an updated_at 
columns to the 
database.

If it's supported in a DB think about adding the current time to the created_at 
if it's null. Don't know 
if we can automate the updated_at on an update?

Original issue reported on code.google.com by geoffl...@gmail.com on 7 Jun 2008 at 2:23

GoogleCodeExporter commented 8 years ago

Original comment by geoffl...@gmail.com on 12 Jun 2008 at 7:34

GoogleCodeExporter commented 8 years ago
what would this be used for? would this get rid of the schemainfo table so that 
each 
table can be looked at individually?

Original comment by dko...@gmail.com on 13 Jun 2008 at 3:27

GoogleCodeExporter commented 8 years ago
It is just a simple helper method to add Date/Time Columns called 'created_at' 
and
'updated_at' for auditing purposes.

Original comment by geoffl...@gmail.com on 13 Jun 2008 at 1:50

GoogleCodeExporter commented 8 years ago
I spent a little time on this thinking it would be pretty easy.  Creating 
columns and
automatically filling created_at are very easy (for sql and mysql, at least). 
updated_at is harder - I wrote some code that generates triggers to do the 
updates,
but it ain't pretty.  And on mysql, the mysql user account needs SUPER 
privileges to
add the trigger.  

I haven't written anything for other providers in as far as automatic updating.
Should be easy as overriding AddTimeStamps, but I don't have the db software to 
test
against.

Attached is a patch for what I have so far.

Original comment by evon...@gmail.com on 9 Aug 2008 at 7:14

Attachments:

GoogleCodeExporter commented 8 years ago
Moving to Milestone 9

Original comment by geoffl...@gmail.com on 14 Feb 2009 at 10:47