Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check creation date of postgres schema?

For debugging purposes I would like to know when are some of my postgres schemas created at- is it possible?

Searched from PostgreSQL and Apartment docs but didn't find any helpful clues.

Environment and tools I'm using:

+---------------+----------+
| Tools         | Version  |
+--------------------------+
| PostgreSQL    | 9.4.1    |
| Ruby          | 2.2.1p85 |
| Ruby on Rails | 4.1.9    |
| Apartment gem | 0.26.1   |
+---------------+----------+

As you can see I use Apartment for creating schemas in my multi-tenant rails application.

like image 430
Andres Avatar asked Dec 06 '25 09:12

Andres


2 Answers

PostgreSQL system catalogs don't store the dates on which database objects were created. You can configure PostgreSQL to log more or less every SQL statement (log_statement setting), but you'd have had to do that beforehand.

like image 122
Mike Sherrill 'Cat Recall' Avatar answered Dec 07 '25 23:12

Mike Sherrill 'Cat Recall'


You could create an event trigger and store the date of this event in a table. And example can be found here

like image 41
Frank Heikens Avatar answered Dec 08 '25 01:12

Frank Heikens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!