Permalink
Browse files

[db] first pass on migration for the app

  • Loading branch information...
1 parent 8d3c592 commit a97b5b0bee79516eab8f806cfb6efc8d19a0edf0 @FotoVerite committed Jan 2, 2013
View
@@ -0,0 +1,3 @@
+class Comment < ActiveRecord::Base
+ belongs_to :commentable, :polymorphic => true
+end
View
@@ -0,0 +1,4 @@
+class Document < ActiveRecord::Base
+ belongs_to :proposal
+ has_many :sections
+end
View
@@ -0,0 +1,7 @@
+class Link < ActiveRecord::Base
+
+ belongs_to :proposal
+
+ KIND = [:documentation, :spec]
+
+end
@@ -0,0 +1,6 @@
+class Organization < ActiveRecord::Base
+
+ has_many :participants
+ has_many :proposals
+
+end
View
@@ -0,0 +1,6 @@
+class Paragraph < ActiveRecord::Base
+ belongs_to :section
+ has_many :sentences
+ has_many :comments, :as => :commentable
+
+end
@@ -0,0 +1,4 @@
+class Participant < ActiveRecord::Base
+ belongs_to :organization
+ has_many :votes
+end
View
@@ -0,0 +1,6 @@
+class Proposal < ActiveRecord::Base
+ belongs_to :organization
+ has_one :document
+ has_many :votes
+ has_many :links
+end
View
@@ -0,0 +1,5 @@
+class Section < ActiveRecord::Base
+ belongs_to :document
+ has_many :paragraphs
+ has_many :comments, :as => :commentable
+end
View
@@ -0,0 +1,4 @@
+class Sentence < ActiveRecord::Base
+ belongs_to :paragraph
+ has_many :comments, :as => :commentable
+end
View
@@ -0,0 +1,4 @@
+class Vote < ActiveRecord::Base
+ belongs_to :proposal
+ belongs_to :participant
+end
@@ -0,0 +1,8 @@
+class CreateOrganizations < ActiveRecord::Migration
+ def change
+ create_table :organizations do |t|
+ t.string :name
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,11 @@
+class CreateParticipants < ActiveRecord::Migration
+ def change
+ create_table :participants do |t|
+ t.string :first_name
+ t.string :last_name
+ t.string :email
+ t.string :username #You'll thank me
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,8 @@
+class CreateProposals < ActiveRecord::Migration
+ def change
+ create_table :proposals do |t|
+ t.references :organization
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,9 @@
+class CreateVotes < ActiveRecord::Migration
+ def change
+ create_table :votes do |t|
+ t.references :participant, :proposal
+ t.integer :value
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,9 @@
+class CreateLinks < ActiveRecord::Migration
+ def change
+ create_table :links do |t|
+ t.string :kind, :default => :documentation
+ t.string :url
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,9 @@
+class CreateDocuments < ActiveRecord::Migration
+ def change
+ create_table :documents do |t|
+ t.text :abstract
+ t.text :summary
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,10 @@
+class CreateSections < ActiveRecord::Migration
+ def change
+ create_table :sections do |t|
+ t.references :document
+ t.string :title
+ t.integer :position
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,10 @@
+class CreateParagraphs < ActiveRecord::Migration
+ def change
+ create_table :paragraphs do |t|
+ t.references :section
+ t.integer :position
+ t.string :kind
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,9 @@
+class CreateSentences < ActiveRecord::Migration
+ def change
+ create_table :sentences do |t|
+ t.references :paragraph
+ t.text :content
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,10 @@
+class CreateComments < ActiveRecord::Migration
+ def change
+ create_table :comments do |t|
+ t.text :content
+ t.integer :commentable_id
+ t.string :commentable_type
+ t.timestamps
+ end
+ end
+end
View
@@ -0,0 +1,90 @@
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 20130104175419) do
+
+ create_table "comments", force: true do |t|
+ t.text "content"
+ t.integer "commentable_id"
+ t.string "commentable_type"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "documents", force: true do |t|
+ t.text "abstract"
+ t.text "summary"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "links", force: true do |t|
+ t.string "kind", default: "documentation"
+ t.string "url"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "organizations", force: true do |t|
+ t.string "name"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "paragraphs", force: true do |t|
+ t.integer "section_id"
+ t.integer "position"
+ t.string "kind"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "participants", force: true do |t|
+ t.integer "organization_id"
+ t.string "first_name"
+ t.string "last_name"
+ t.string "email"
+ t.string "username"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "proposals", force: true do |t|
+ t.integer "organization_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "sections", force: true do |t|
+ t.integer "document_id"
+ t.string "title"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "sentences", force: true do |t|
+ t.integer "paragraph_id"
+ t.text "content"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "votes", force: true do |t|
+ t.integer "participant_id"
+ t.integer "proposal_id"
+ t.integer "value"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+end
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Comment do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Document do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
View
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Link do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Organization do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Paragraph do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Participant do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Proposal do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Section do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Sentence do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
View
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Vote do
+ pending "add some examples to (or delete) #{__FILE__}"
+end

0 comments on commit a97b5b0

Please sign in to comment.