Sequel.migration do
  up do
    create_table :section_notes do
      primary_key :id
      foreign_key :section_id, :sections
      String :content, text: true
    end

    create_table :chapter_notes do
      primary_key :id
      foreign_key :section_id, :sections
      Integer :chapter_id, index: true
      String :content, text: true
    end
  end

  down do
    drop_table :section_notes
    drop_table :chapter_notes
  end
end

Sequel.migration do
  up do
    create_table :section_notes do
      primary_key :id
      index :section_id
      String :content, text: true
    end

    create_table :chapter_notes do
      primary_key :id
      index :section_id
      Integer :chapter_id, index: true
      String :content, text: true
    end
  end

  down do
    drop_table :section_notes
    drop_table :chapter_notes
  end
end

Use plain indexes, without FK constraints.
Use plain indexes, without FK constraints.

FK constraints yield problems if TRUNCATE is used. FK logic should be
handled Rails way (by the application).
