Commit Graph

24 Commits

Author SHA1 Message Date
Javi Martín
d137df67bf Fix release version number in rake tasks
When we added the tasks, we thought the new version was going to be
version 1.6.0, but in the end we're renaming it to version 2.0.0.
2023-07-13 17:48:26 +02:00
Javi Martín
c483c6036a Install extensions in a shared schema
This way all tenants will be able to access them instead of just the
default one.

The apartment gem recommends using a rake task instead of a migration,
but that's a solution which is primarily meant for new installations.
Migrations are easier to execute on existing installations.

However, since this migration doesn't affect the `schema.rb` file, we
still need to make sure the shared schema is created in tasks which do
not execute migrations, like `db:schema:load` or `db:test:prepare`, just
like the apartment gem recommends. That's why we're enhancing these
tasks so they execute this migration.

Note that there might be cases where the database user isn't a superuser
(as it's usually the case on production environments), meaning commands
to create, alter or drop extensions will fail. There's also the case
where users don't have permissions to create schemas, which is needed in
order to create the shared extensions schema and the schemas used by the
tenants. For these reasons, we're minimizing the number of commands, and
so we only alter or create extensions when it is really necessary.

When users don't have permission, we aren't running the commands but
showing a warning with the steps needed to run the migration manually.
This is only necessary on installations which are going to use
multitenancy; single-tenant applications upgrading don't need to run
this migration, and that's why we aren't raising exceptions when we
can't run it.

For new installations, we'll change the CONSUL installer so extensions
are automatically created in the shared schema.

Also note the plpgsql extension is not handled here. This is a special
extension which must be installed on the pg_catalog schema, which is
always in the search path and so is shared by all tenants.

Finally, we also need to change the `database.yml` file in order to
search for shared extensions while running migrations or model tests,
since none of our enabled extensions are executed during migrations;
we're also adding a rake task for existing installations. Quoting the
apartment documentation:

> your database.yml file must mimic what you've set for your default and
> persistent schemas in Apartment. When you run migrations with Rails,
> it won't know about the extensions schema because Apartment isn't
> injected into the default connection, it's done on a per-request
> basis.
2022-11-09 17:53:31 +01:00
Javi Martín
5719f32758 Remove tasks to upgrade to version 1.5.0
These tasks are not needed for new installations, and in existing
installations they've already been executed when upgrading to version
1.5.0.
2022-10-02 16:52:59 +02:00
Javi Martín
5a0fde4048 Allow selecting the time when a poll starts/ends
We were already saving it as a time, but we didn't offer an interface to
select the time due to lack of decent browser support for this field
back when this feature was added.

However, nowadays all major browsers support this field type and, at the
time of writing, at least 86.5% of the browsers support it [1]. This
percentage could be much higher, since support in 11.25% of the browsers
is unknown.

Note we still need to support the case where this field isn't supported,
and so we offer a fallback and on the server side we don't assume we're
always getting a time. We're doing a strange hack so we set the field
type to text before changing its value; otherwise old Firefox browsers
crashed.

Also note that, until now, we were storing end dates in the database as
a date with 00:00 as its time, but we were considering the poll to be
open until 23:59 that day. So, in order to keep backwards compatibility,
we're adding a task to update the dates of existing polls so we get the
same behavior we had until now.

This also means budget polls are now created so they end at the
beginning of the day when the balloting phase ends. This is consistent
with the dates we display in the budget phases table.

Finally, there's one test where we're using `beginning_of_minute` when
creating a poll. That's because Chrome provides an interface to enter a
time in a `%H:%M` format when the "seconds" value of the provided time
is zero. However, when the "seconds" value isn't zero, Chrome provides
an interface to enter a time in a `%H:%M:%S` format. Since Capybara
doesn't enter the seconds when using `fill_in` with a time, the test
failed when Capybara tried to enter a time in the `%H:%M` format when
Chrome expected a time in the `%H:%M:%S` format.

To solve this last point, an alternative would be to manually provide
the format when using `fill_in` so it includes the seconds.

[1] https://caniuse.com/mdn-html_elements_input_type_datetime-local
2022-09-14 15:14:23 +02:00
Jacek Skrzypacz
2af7e32415 Add search form for hidden content
Added search for comments and proposal_notifications, added tsv column
for search and rake tasks to update/create tsv vector.
2022-08-23 14:30:38 +02:00
Javi Martín
7212657c02 Remove Paperclip and use just Active Storage 2022-02-23 18:43:48 +01:00
Javi Martín
1b2256e084 Remove tasks to upgrade to version 1.3.0
These tasks are not needed for new installations, and in existing
installations they've already been executed when upgrading to version
1.3.0.
2021-10-06 13:51:56 +02:00
Javi Martín
619d402f92 Add task to migrate files to Active Storage
This task was copied from Thoughtbot's migration guide [1]. They use a
migration file, but we usually use rake tasks to migrate data.

[1] https://github.com/thoughtbot/paperclip/blob/master/MIGRATING.md
2021-09-24 13:39:15 +02:00
Javi Martín
d06031c427 Don't run release 1.3.0 tasks anymore
People who have already upgraded to version 1.3.0 don't need to execute
them again.

We're not deleting the tasks yet in case some people would like to
upgrade from version 1.2.0 to version 1.3.1. In this case, they'll have
to execute the tasks manually.
2021-06-03 17:24:46 +02:00
Julian Herrero
909071c48b Allow editing the name of budget phases
Co-authored-by: decabeza <alberto@decabeza.es>
2021-03-11 19:37:58 +01:00
decabeza
c0c458bb38 Remove summary in phases form
Since it does not appear in the phases anymore.

Also, the rake unifies the fields of the budget summary with the budget
description.
2021-03-11 19:37:58 +01:00
Julian Herrero
77aaa5e973 Add task to set published on existing budgets
Note we're making the validation rule dynamic so it's affected by the
way we stub the constant in the tests to emulate data created in old
applications.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2021-02-23 17:05:24 +01:00
Javi Martín
852014e478 Add search method to polls
So far the method does not take questions nor answers into account.

This way we'll be able to search polls in the SDG Management section.
2020-12-21 18:04:48 +01:00
Senén Rodero Rodríguez
c7c8309ad1 Add rake task to load sdg
This task should be useful for existing installations that are going
to upgrade the app and want to load SDG data into an already
existing database.
2020-12-02 12:38:03 +01:00
Javi Martín
9837b1ab74 Remove tasks to upgrade to version 1.1
These tasks are not needed for new installations, and in existing
installations they've already been executed when upgrading to version
1.1.

One of them also raises a warning in Rails 5.2:

DEPRECATION WARNING: Dangerous query method (method whose arguments are
used as raw SQL) called with non-attribute argument(s): "MIN(id) as id".
Non-attribute arguments will be disallowed in Rails 6.0. This method
should not be called with user-provided values, such as request
parameters or model attributes. Known-safe values can be passed by
wrapping them in Arel.sql()
2020-07-08 18:34:58 +02:00
taitus
4bb194e1cc Recover rake "settings:rename_setting_keys"
We need to add :rename_setting_keys before :add_new_settings task.
This way the value of the old key will not be lost.
2020-02-19 16:14:44 +01:00
Javi Martín
9b511edd5b Write task to migrate budget admins and valuators
If we didn't run this task, investments for existing budgets wouldn't
show their administrator/valuators as an option when we're editing them,
leading to data loss.
2019-11-01 17:12:42 +01:00
Javi Martín
b8fbd6347b Use acts_as_taggable for investment valuation tags
We were manually doing the same thing, generating inconsistent results,
since the method `valuation_tag_list` was using the `valuation` context,
when actually the expected behavior would be to use the `valuation_tag`
context.
2019-11-01 17:12:31 +01:00
Javi Martín
acbad38749 Update execute_release_tasks task
It now contains tasks we've added after version 1.0.0
2019-10-08 20:20:41 +02:00
Javi Martín
7bb39c8e4e Execute add_new_settings on every release
Although it's already executed when deploying with capistrano, heroku
installations don't use capistrano for deployment, so we're also
executing it when upgrading.

This isn't a one-time task, so it makes sense to have it executed on
every release.
2019-10-08 20:19:48 +02:00
Javi Martín
8fb44961e9 Remove tasks to rename/remove deprecated settings
I was thinking of leaving these tasks empty, so in the future we could
use them again if we rename or remove more settings. But since we
haven't renamed nor removed any settings for more than seven months, and
we've only used these tasks once, I'm simply removing the tasks. It's
easy to add them back if we ever need them.
2019-10-08 20:19:48 +02:00
Javi Martín
122b066573 Remove already executed tasks
These tasks were executed when upgading to version 0.19, 1.0.0-beta or
1.0.0.
2019-10-08 20:19:48 +02:00
Pierre Mesure
2705416842 Adding missing subtasks to upgrade task and adding info log 2019-06-11 22:35:57 +02:00
Javi Martín
c78211af49 Add task to upgrade to version 1.0.0
It includes every task needed for the upgrade.
2019-06-05 20:23:54 +02:00