# Determining the version from the database

**URL:** https://meta.discourse.org/t/determining-the-version-from-the-database/164625
**Category:** Support
**Created:** [September 20, 2020, 11:25am UTC](https://meta.discourse.org/t/determining-the-version-from-the-database/164625 "2020-09-20T11:25:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![csmu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/csmu/32/124581_2.png) [@csmu](https://meta.discourse.org/u/csmu)
#### Post date: [September 20, 2020, 11:25am UTC](https://meta.discourse.org/t/determining-the-version-from-the-database/164625/1 "2020-09-20T11:25:41Z")

</div>

How would you determine the current version of discourse within the database?

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [September 20, 2020, 1:36pm UTC](https://meta.discourse.org/t/determining-the-version-from-the-database/164625/2 "2020-09-20T13:36:23Z")

</div>

Find the most recent entry in the migrations table.

---

<div class="post-metadata">

### Author: ![csmu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/csmu/32/124581_2.png) [@csmu](https://meta.discourse.org/u/csmu)
#### Post date: [September 21, 2020, 12:22am UTC](https://meta.discourse.org/t/determining-the-version-from-the-database/164625/3 "2020-09-21T00:22:45Z")

</div>

Example

```sql

select table_name from information_schema.tables where table_schema = 'public' and table_name like 'schema%' order by table_name ;
        table_name        
--------------------------
 schema_migration_details
 schema_migrations
 
 select version from schema_migrations order by version desc limit 1 ;
     version     
 ----------------
  20200203061927
  
  discourse=# select version, name, git_version, rails_version from schema_migration_details where version in ( select version from schema_migrations order by version desc limit 10 ) order by version desc ;
      version | name | git_version | rails_version 
  ----------------+-------------------------------------------------+------------------------------------------+---------------
   20200203061927 | MarkBookmarksTopicIdNotNull | 31f3ed8d3610b63c7b1146e1a67ee51b703dbc41 | 6.0.1
   20200130115859 | RemoveBounceScoreThresholdDeactivateSiteSetting | 31f3ed8d3610b63c7b1146e1a67ee51b703dbc41 | 6.0.1
   20200121120800 | CorrectUserNotesCount | 31f3ed8d3610b63c7b1146e1a67ee51b703dbc41 | 6.0.1
   20200120140900 | AddUserNotesCountIndex | 31f3ed8d3610b63c7b1146e1a67ee51b703dbc41 | 6.0.1
   20200120131338 | DropUnusedColumns | 31f3ed8d3610b63c7b1146e1a67ee51b703dbc41 | 6.0.1
   20200117174646 | MakePostReplyIdColumnReadOnly | 31f3ed8d3610b63c7b1146e1a67ee51b703dbc41 | 6.0.1
   20200117172135 | AddTriggerToSyncPostReplies | 31f3ed8d3610b63c7b1146e1a67ee51b703dbc41 | 6.0.1
   20200117141138 | UpdatePostReplyIndexes | 31f3ed8d3610b63c7b1146e1a67ee51b703dbc41 | 6.0.1
   20200116140132 | RenameReplyIdColumn | 31f3ed8d3610b63c7b1146e1a67ee51b703dbc41 | 6.0.1
   20200109130028 | UpdateUserProfilesIndexes | 31f3ed8d3610b63c7b1146e1a67ee51b703dbc41 | 6.0.1
  (10 rows)
  

```

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [October 21, 2020, 12:23am UTC](https://meta.discourse.org/t/determining-the-version-from-the-database/164625/4 "2020-10-21T00:23:53Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
