Database migration question

(Mike) #1

This is a general Rails question. There is migration file called 20120311163914_create_forum_threads inside the migration folder with contents:

class CreateForumThreads < ActiveRecord::Migration
  def change
   create_table :forum_threads do |t|
     t.integer :forum_id, null: false
     t.string :title, null: false
     t.integer :last_post_id
     t.datetime :last_posted_at

Just wondering why this table (forum_threads) isn’t created in the discourse_development database? I can see many other tables but not this one. Isn’t this migration creating a table called forum_threads?

An SQL query of SELECT * FROM forum_threads says this table doesn’t exist.

(Alan Tan) #2

That is because a single migration file does not represent the current schema in the database. There can be other migrations which alter the schema of the database like the following:

I’m not sure why Discourse doesn’t store the schema in schema.rb like most Rails apps do though. Instead look into structure.sql for the latest schema.

(Mike) #3

Can @sam answer this?

(Sam Saffron) #4

We use some pg features that rails does not write to schema.rb