db_schema.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. SCHEMA_STATEMENTS = [
  2. '''
  3. create table if not exists localities (
  4. id integer not null primary key,
  5. name varchar(255) not null
  6. );
  7. ''',
  8. '''
  9. create table if not exists locality_relationships (
  10. id varchar(255) not null primary key,
  11. parent integer not null,
  12. child integer not null
  13. )
  14. ''',
  15. '''
  16. create table if not exists search_results (
  17. id integer not null primary key,
  18. time datetime not null,
  19. property_id integer not null,
  20. price integer not null,
  21. raw_json text not null
  22. )
  23. ''',
  24. '''
  25. create table if not exists properties (
  26. id integer not null primary key,
  27. last_update datetime not null,
  28. raw_json text not null
  29. )
  30. ''',
  31. 'alter table properties add column processed tinyint default 0 not null;',
  32. 'alter table properties add column price integer;',
  33. 'alter table properties add column lat float;',
  34. 'alter table properties add column lon float;',
  35. 'alter table properties add column size;',
  36. 'alter table properties add column ber varchar(255);',
  37. 'drop table properties;',
  38. '''
  39. create table properties (
  40. id integer not null primary key,
  41. last_update datetime not null,
  42. raw_json text,
  43. processed tinyint default 0 not null,
  44. price integer,
  45. lat float,
  46. lon float,
  47. size integer,
  48. ber varchar(255)
  49. )
  50. ''',
  51. 'alter table properties add column address varchar(1023)',
  52. 'alter table properties add column locality_id integer',
  53. 'alter table properties add column property_type varchar(255)',
  54. 'alter table properties add column bathrooms integer',
  55. 'alter table properties add column bedrooms integer',
  56. '''
  57. create table property_locality_map (
  58. id varchar(255) primary key not null,
  59. property_id integer not null,
  60. locality_id integer not null
  61. )
  62. ''',
  63. ]