Commit Graph

33 Commits

Author SHA1 Message Date
Klaas van Schelven 12d7ce5629 Flake8: for migrations _just_ ignore the whitespace errors
this helps catching some _real_ errors while saving us from having to format
automatically generated code
2025-02-06 16:41:43 +01:00
Klaas van Schelven 86e8c4318b Add indexes on fields on which we order and vice versa
Triggered by issue_event_list being more than 5s on "emu" (my 1,500,000 event
test-machine). Reason: sorting those events on non-indexed field. Switching
to a field-with-index solved it.

I then analysed (grepped) for "ordering" and "order_by" and set indexes
accordingly and more or less indiscriminately (i.e. even on tables that are
assumed to have relatively few rows, such as Project & Team).
2025-02-04 21:19:24 +01:00
Klaas van Schelven 0b42d3ff1e Semi-manual squash-migrations
## Goal

Reduce the number of migrations for _fresh installs_ of Bugsink. This implies: squash as
broadly as possible.

## How?

"throw-away-and-rerun". In particular, for a given app:

* throw away the migrations from some starting point up until and including the last one.
* run "makemigrations" for that app. Django will see what's missing and just redo it
* rename to 000n_b_squashed or similar.
* manually set a `replaces` list on the migration to the just-removed migrations
* manually check dependencies; check that they are:
    * as low as possible, e.g. an FK should only depend on existence. this reduces the
      risk of circular dependencies.
    * pointing to "original migrations", i.e. not to a just-created squashed migration.
      because the squashed migrations "contain a lot" they increase the risk of circular
      dependencies.
* restore (git checkout) the thrown-away migration

## Further tips:

* "Some starting point" is often not 0000, but some higher number (see e.g. the outcome
  in the present commit). Leaving the migrations for creation of base models (Event,
  Issue, Project) in place saves you from a lot of circular dependency problems.
* Move db.sqlite3 out of the way to avoid superfluous warnings.

## RunPython worries

I grepped for RunPython in the replaced migrations, with the following results:

* phonehome's create_installation_id was copied-over to the squashed migration.
* all others where ignored, because:
    * they "do something with events", i.e. only when events are present will they have
      an effect. This means they are no-ops for _new installs_.
    * for existing installs, for any given app, they will only be missed (replaced) when
      the first replaced migration is not yet executed.

I used the following command (reading from the bottom) to establish that this means only
people that did a fresh install after 8ad6059722 (June 14, 2024), but before
c01d332e18 (July 16) _and then never did any upgrades_ would be affected. There are no
such people.

git log --name-only \
    events/migrations/0004_event_irrelevance_for_retention.py \
    issues/migrations/0004_rename_event_count_issue_digested_event_count.py \
    phonehome/migrations/0001_initial.py \
    projects/migrations/0002_initial.py \
    teams/migrations/0001_initial.py

Note that the above observation still be true for the next squashmigration (assuming
squashing starting at the same starting migrations).

## Cleanup of the replaced migrations

Django says:

> Once you’ve squashed your migration, you should then commit it alongside the
> migrations it replaces and distribute this change to all running instances of your
> application, making sure that they run migrate to store the change in their database.

Given that I'm not in control of all running instances of my application, this means the
cleanup must not happen "too soon", and only after announcing a migration path ("update
to version X before updating to version Y").

## Roads not taken

Q: Why not just do squashmigrations? A: It didn't work reliably (for me), presumably b/c
of the high number of strongly interdependant apps in combination with some RunPython.

Seen after I was mostly done, not explored seriously (yet):

* https://github.com/3YOURMIND/django-replace-migrations
* https://pypi.org/project/django-squash/
* https://django-extensions.readthedocs.io/en/latest/delete_squashed_migrations.html
2025-02-03 16:06:17 +01:00
Klaas van Schelven 0ec809cbb3 Simplify migration deps and document them 2025-02-03 14:04:44 +01:00
Klaas van Schelven c6adfd7511 Remove 'slug' field from team
it was unused; probably added analogously with project (where it _is_ used)
2025-01-24 10:21:39 +01:00
Klaas van Schelven 944f9d9a84 Add title tags to (parent elements of) svg icons 2024-11-29 08:25:11 +01:00
Klaas van Schelven cf4a1dbeb6 Project/team help_text 2024-11-20 14:33:04 +01:00
Klaas van Schelven b43d1cfa05 action must be non-empty 2024-09-26 15:27:46 +02:00
Klaas van Schelven 23b2a70797 remove magic number in favor of method 2024-09-17 21:36:41 +02:00
Klaas van Schelven eec8d51491 Remove various non-TODOs
either already done, or more of a 'this is a way this code could potentially
evolve in the future' (but not a 'we must do this')
2024-09-13 10:05:22 +02:00
Klaas van Schelven d4d292e4be Remove perm-based permission-checks
For now, sticking to "how it actually works" is more important than "what we
might need in the future". We don't have an admin-group with actually handed
out perms yet, and we do have the recommendation to create a superuser in the
installation docs. So let's just explicity check for that.

(I found these checks while working on actual breakage in the previous commit)
2024-09-10 08:51:00 +02:00
Klaas van Schelven 3b0b11d069 Fix team creation permissions
settings.TEAM_CREATION was simply unused; an oversight.
2024-09-10 08:48:46 +02:00
Klaas van Schelven a8c5e447c8 atomic_for_request_method: put on teams/projects views too
discovered while playing with mysql;
drive-by change, i.e. not yet tested.
2024-08-28 15:08:41 +02:00
Klaas van Schelven 129a8db421 Fix various flake8 errors 2024-08-21 09:31:05 +02:00
Klaas van Schelven b77fc630e5 Rename 'visible' => 'discoverable'
more clear that it's just the 'front door' we're talking about
2024-06-17 11:08:29 +02:00
Klaas van Schelven 0e199633b9 Rename 'visible' => 'discoverable'
more clear that it's just the 'front door' we're talking about
2024-06-17 11:08:02 +02:00
Klaas van Schelven 8ad6059722 Complete migration reset 2024-06-14 10:29:10 +02:00
Klaas van Schelven 95cb39f5af Implement 'send_email_alerts'
* cascading from team to project; user is base-level-default
* implemented at form-level
* implemented when emails are actually sent
2024-06-13 13:23:14 +02:00
Klaas van Schelven 33f2d55eab SINGLE_TEAM & SINGLE_USER implemented
in-template only; since we make source available it's a bit silly to put all kinds
of 'security' in place that could easily be edited out
2024-06-10 15:41:54 +02:00
Klaas van Schelven f614d0c26a full width form fields 'everywhere'
also distinguish between labeled/placeholder style
2024-06-10 14:24:55 +02:00
Klaas van Schelven d71916940a Factor out 'tailwind_formfield' tag 2024-06-10 10:00:06 +02:00
Klaas van Schelven de8bd65a3a WIP teams & project-management (6)
not extensively tested, but it starts to feel quite complete 'for now'
2024-06-07 10:52:25 +02:00
Klaas van Schelven 07a3de6c8d Superuser overrides for team-editing; hidden teams actually hidden 2024-06-06 11:12:32 +02:00
Klaas van Schelven 004b586e2d The most basic of 'onboarding', as it pertains to teams 2024-06-06 10:54:56 +02:00
Klaas van Schelven beef63b5d5 Permission checks on team views 2024-06-06 10:42:31 +02:00
Klaas van Schelven cd588e95bc Fixes to team-accept view 2024-06-06 10:33:13 +02:00
Klaas van Schelven ecc3b9a8d2 Permission check for site-level-invite-from-teams 2024-06-06 09:43:28 +02:00
Klaas van Schelven 42ba4cc99c Put mail templates in a so-named directory 2024-06-06 09:38:43 +02:00
Klaas van Schelven de190e594f WIP teams & project-management (5) 2024-06-06 09:26:07 +02:00
Klaas van Schelven 0e4f13838e WIP teams & project-management (4) 2024-06-05 22:36:05 +02:00
Klaas van Schelven d0bfa668ba WIP teams & project-management (3) 2024-06-05 20:23:28 +02:00
Klaas van Schelven 7dddf45a04 WIP teams & project-management (2) 2024-06-04 11:19:19 +02:00
Klaas van Schelven 9d9cac3e9d WIP teams & project-management 2024-06-03 22:30:10 +02:00