# timestamp\_on\_create type not working for built in MySQL DB

**URL:** <https://community.dreamfactory.com/t/timestamp-on-create-type-not-working-for-built-in-mysql-db/255>\
**Category:** Schema & Data\
**Created:** [August 13, 2014, 7:18pm UTC](https://community.dreamfactory.com/t/timestamp-on-create-type-not-working-for-built-in-mysql-db/255 "2014-08-13T19:18:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkromhout](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/bkromhout/32/223_2.png) [@bkromhout](https://community.dreamfactory.com/u/bkromhout)\
**Post date:** [August 13, 2014, 7:18pm UTC](https://community.dreamfactory.com/t/timestamp-on-create-type-not-working-for-built-in-mysql-db/255/1 "2014-08-13T19:18:13Z")

</div>

Hello, I’ve noticed that even though I have a column in some of my tables set to the “timestamp\_on\_create” dreamfactory type, as of 1.7.1, the timestamp is getting set to this zero string: “0000-00-00 00:00:00” in the database, even though it was working correctly in 1.6.10 and setting the correct timestamps when data was posted. (This is for the internal MySQL database by the way.)  
(I realize that in the default field in the schema editor, that zero string is what it is set to for the timestamp\_on\_create type. Again, this was fine in 1.6.10, it still put in the actual timestamp when I posted data, but in 1.7.1, it actually does fill the column in with that default zero string, which is obviously a problem.)

I’ve created a workaround by manually going into the database with phpmyadmin and setting that column’s default value to be CURRENT\_TIMESTAMP, which makes it work as expected. However, if I make any changes and save them with dreamfactory’s schema editor, it switches it back to the default being “0000-00-00 00:00:00”, which makes any data being posted have have that column filled in with that zero string.

I’ve made sure that the dreamfactory type is “timestamp\_on\_create”, the database type is “timestamp”, and that the validation field is filled in as “api\_read\_only”, but it still won’t correctly fill in the timestamp when data is posted like it would on 1.6.10. I can keep doing the workaround every time I edit the schema using dreamfactory’s schema editor, but I assume we would also like to fix the bug here, so any help you could give me would be great.

Thanks!

---

<div class="post-metadata">

**Author:** ![Mark](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/mark/32/69_2.png) [@Mark](https://community.dreamfactory.com/u/Mark)\
**Post date:** [August 13, 2014, 7:26pm UTC](https://community.dreamfactory.com/t/timestamp-on-create-type-not-working-for-built-in-mysql-db/255/2 "2014-08-13T19:26:09Z")

</div>

Hey - we appreciate the heads up on this issue. Our engineers are looking into this, and we’ll have an update for you soon.

Thanks again,

- Mark

---

<div class="post-metadata">

**Author:** ![bkromhout](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/bkromhout/32/223_2.png) [@bkromhout](https://community.dreamfactory.com/u/bkromhout)\
**Post date:** [August 13, 2014, 7:27pm UTC](https://community.dreamfactory.com/t/timestamp-on-create-type-not-working-for-built-in-mysql-db/255/3 "2014-08-13T19:27:51Z")

</div>

Thanks Mark, you’ve been awesome with the help today!

---

<div class="post-metadata">

**Author:** ![Mark](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/mark/32/69_2.png) [@Mark](https://community.dreamfactory.com/u/Mark)\
**Post date:** [August 13, 2014, 8:05pm UTC](https://community.dreamfactory.com/t/timestamp-on-create-type-not-working-for-built-in-mysql-db/255/4 "2014-08-13T20:05:01Z")

</div>

Hey,

No worries man! Try setting that service\_id column to your actual service\_id (from df\_sys\_service table in phpmyadmin) of the db service… then you should be in business.

Let me know how this works.

Thanks,

- Mark

---

<div class="post-metadata">

**Author:** ![bkromhout](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/bkromhout/32/223_2.png) [@bkromhout](https://community.dreamfactory.com/u/bkromhout)\
**Post date:** [August 13, 2014, 8:15pm UTC](https://community.dreamfactory.com/t/timestamp-on-create-type-not-working-for-built-in-mysql-db/255/5 "2014-08-13T20:15:49Z")

</div>

Hey Mark, maybe I’m getting a bit turned around, but I’m not sure what you mean by a service\_id column for my table schema. I was having a problem with a column that I created that I have set as dreamfactory type of “timestamp\_on\_create” with DB type “timestamp”. I’m using the built in MySQL database for these tables, so I’m not sure if maybe the service\_id you’re talking about still applies, I’m not seeing anything like that.

---

<div class="post-metadata">

**Author:** ![leehicks](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/leehicks/32/55_2.png) [@leehicks](https://community.dreamfactory.com/u/leehicks)\
**Post date:** [August 13, 2014, 9:21pm UTC](https://community.dreamfactory.com/t/timestamp-on-create-type-not-working-for-built-in-mysql-db/255/6 "2014-08-13T21:21:17Z")

</div>

There is another table called df\_sys\_schema\_extras where the xxx\_on\_create and xxx\_on\_update schema settings are kept. Previous releases failed to set the mapped service\_id field (you will see a null value there). There is a row for each table-field combo. Set this to the id of your service (from the df\_sys\_service table, probably 1 since that has typically been the first service created).

I have a new version with this and another fix coming up shortly.

---

<div class="post-metadata">

**Author:** ![bkromhout](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/bkromhout/32/223_2.png) [@bkromhout](https://community.dreamfactory.com/u/bkromhout)\
**Post date:** [August 13, 2014, 9:49pm UTC](https://community.dreamfactory.com/t/timestamp-on-create-type-not-working-for-built-in-mysql-db/255/7 "2014-08-13T21:49:28Z")

</div>

Sounds good, I’ll watch out for it.
