Add Cadastre table

This commit is contained in:
Xavier J 2016-01-15 15:28:56 +01:00
parent 0f93aba6bc
commit b5f2163c51
4 changed files with 56 additions and 1 deletions

7
app/models/cadastre.rb Normal file
View file

@ -0,0 +1,7 @@
class Cadastre < ActiveRecord::Base
belongs_to :dossier
def geometry
JSON.parse(read_attribute(:geometry))
end
end

View file

@ -0,0 +1,18 @@
class CreateCadastreTable < ActiveRecord::Migration
def change
create_table :cadastres do |t|
t.string :surface_intersection
t.float :surface_parcelle
t.string :numero
t.integer :feuille
t.string :section
t.string :code_dep
t.string :nom_com
t.string :code_com
t.string :code_arr
t.text :geometry
end
add_reference :cadastres, :dossier, references: :dossiers
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160106100227) do
ActiveRecord::Schema.define(version: 20160115135025) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -35,6 +35,20 @@ ActiveRecord::Schema.define(version: 20160106100227) do
add_index "administrateurs", ["email"], name: "index_administrateurs_on_email", unique: true, using: :btree
add_index "administrateurs", ["reset_password_token"], name: "index_administrateurs_on_reset_password_token", unique: true, using: :btree
create_table "cadastres", force: :cascade do |t|
t.string "surface_intersection"
t.float "surface_parcelle"
t.string "numero"
t.integer "feuille"
t.string "section"
t.string "code_dep"
t.string "nom_com"
t.string "code_com"
t.string "code_arr"
t.text "geometry"
t.integer "dossier_id"
end
create_table "cerfas", force: :cascade do |t|
t.string "content"
t.integer "dossier_id"

View file

@ -0,0 +1,16 @@
require 'spec_helper'
describe Cadastre do
it { is_expected.to have_db_column(:surface_intersection) }
it { is_expected.to have_db_column(:surface_parcelle) }
it { is_expected.to have_db_column(:numero) }
it { is_expected.to have_db_column(:feuille) }
it { is_expected.to have_db_column(:section) }
it { is_expected.to have_db_column(:code_dep) }
it { is_expected.to have_db_column(:nom_com) }
it { is_expected.to have_db_column(:code_com) }
it { is_expected.to have_db_column(:code_arr) }
it { is_expected.to have_db_column(:geometry) }
it { is_expected.to belong_to(:dossier) }
end