Election results in the London Borough of Sutton.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

78 lines
2.3 KiB

  1. class Postcode
  2. include DataMapper::Resource
  3. property :id, Serial
  4. property :postcode, String, :required => true
  5. property :created_at, DateTime, :required => true
  6. property :lat, Float, :required => true
  7. property :lng, Float, :required => true
  8. property :district_name, String, :required => true
  9. property :district_code, String, :required => true
  10. property :ward_name, String, :required => true
  11. property :ward_code, String, :required => true
  12. end
  13. class Ward
  14. include DataMapper::Resource
  15. property :id, Serial
  16. property :ons_id, String, :required => true
  17. property :name, String, :required => true
  18. property :constituency_id, Integer, :required => true
  19. has n, :councilcandidates
  20. belongs_to :constituency
  21. end
  22. class Party
  23. include DataMapper::Resource
  24. property :id, Serial
  25. property :name, String, :required => true
  26. has n, :councilcandidates
  27. has n, :parliamentcandidates
  28. end
  29. class Councilcandidate
  30. include DataMapper::Resource
  31. property :id, Serial
  32. property :ward_id, Integer, :required => true
  33. property :party_id, Integer, :required => true
  34. property :forenames, String, :required => true
  35. property :surname, String, :required => true
  36. property :address, String, :length => 200
  37. property :postcode, String, :required => true
  38. belongs_to :party
  39. belongs_to :ward
  40. end
  41. class Parliamentcandidate
  42. include DataMapper::Resource
  43. property :id, Serial
  44. property :constituency_id, Integer, :required => true
  45. property :party_id, Integer, :required => true
  46. property :forenames, String, :required => true
  47. property :surname, String, :required => true
  48. property :address, String, :length => 200
  49. property :postcode, String
  50. belongs_to :party
  51. belongs_to :constituency
  52. end
  53. class Constituency
  54. include DataMapper::Resource
  55. property :id, Serial
  56. property :name, String, :required => true
  57. has n, :wards
  58. has n, :parliamentcandidates
  59. end
  60. DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/db.sqlite3")
  61. DataMapper.auto_upgrade!