diff options
-rwxr-xr-x | bin/update-schema | 1 | ||||
-rw-r--r-- | db/downgrade_0046---0045.sql | 6 | ||||
-rw-r--r-- | db/schema.sql | 3 | ||||
-rw-r--r-- | db/schema_0046-user-add-extra.sql | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/User.pm | 20 |
5 files changed, 29 insertions, 7 deletions
diff --git a/bin/update-schema b/bin/update-schema index bb0360fb2..500e771f1 100755 --- a/bin/update-schema +++ b/bin/update-schema @@ -194,6 +194,7 @@ else { # By querying the database schema, we can see where we're currently at # (assuming schema change files are never half-applied, which should be the case) sub get_db_version { + return '0046' if column_exists('users', 'extra'); return '0045' if table_exists('response_priorities'); return '0044' if table_exists('contact_response_templates'); return '0043' if column_exists('users', 'area_id'); diff --git a/db/downgrade_0046---0045.sql b/db/downgrade_0046---0045.sql new file mode 100644 index 000000000..c0cc566af --- /dev/null +++ b/db/downgrade_0046---0045.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE users + DROP COLUMN extra; + +COMMIT; diff --git a/db/schema.sql b/db/schema.sql index 27f4bad13..fe45fb4aa 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -31,7 +31,8 @@ create table users ( title text, twitter_id bigint unique, facebook_id bigint unique, - area_id integer + area_id integer, + extra text ); -- Record details of reporting bodies, including open311 configuration details diff --git a/db/schema_0046-user-add-extra.sql b/db/schema_0046-user-add-extra.sql new file mode 100644 index 000000000..06937237c --- /dev/null +++ b/db/schema_0046-user-add-extra.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE users + ADD COLUMN extra TEXT; + +COMMIT; diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm index 2a2d0d5e3..405d9e920 100644 --- a/perllib/FixMyStreet/DB/Result/User.pm +++ b/perllib/FixMyStreet/DB/Result/User.pm @@ -26,20 +26,22 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "password", { data_type => "text", default_value => "", is_nullable => 0 }, - "flagged", - { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "from_body", { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "flagged", + { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "title", { data_type => "text", is_nullable => 1 }, - "facebook_id", - { data_type => "bigint", is_nullable => 1 }, "twitter_id", { data_type => "bigint", is_nullable => 1 }, + "facebook_id", + { data_type => "bigint", is_nullable => 1 }, "is_superuser", { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "area_id", { data_type => "integer", is_nullable => 1 }, + "extra", + { data_type => "text", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->add_unique_constraint("users_email_key", ["email"]); @@ -100,11 +102,17 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-08-03 13:52:28 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SX8BS91mWHoOm2oWdNth1w +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-09-16 14:22:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7wfF1VnZax2QTXCIPXr+vg + +__PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); +__PACKAGE__->rabx_column('extra'); use Moo; use mySociety::EmailUtil; +use namespace::clean -except => [ 'meta' ]; + +with 'FixMyStreet::Roles::Extra'; __PACKAGE__->many_to_many( planned_reports => 'user_planned_reports', 'report' ); |