Ghost/core/server/data
Matt Hanley d4700e048a Mapped subscribers to newsletter (#14518)
Closes https://github.com/TryGhost/Team/issues/1508
Refs https://github.com/TryGhost/Ghost/pull/14468

- Maps existing subscribers to the default newsletter

A note on performance:
We loop over the rows in a potentially large table (members) but I've minimised the impact by limiting the columns we fetch. The alternative is a raw SQL query like the one below: the SQL version takes ~0.9s vs ~1.1s for the migration (my laptop, ~30k members). The disadvantage of the raw SQL implementation is the approximation of the ObjectID (instead of a legit bson ID) which isn't sequential and may impact index size/performance.

```sql
insert into members_newsletters (id, member_id, newsletter_id)
    select
        substr(replace(uuid(),'-',''),1,24),
        id,
        '62595dcbfad4e031d85d166f'
    from members
    where members.subscribed=true;
```
2022-04-26 12:31:34 +01:00
..
db Switched to mysql2 library 2022-03-03 09:59:37 +01:00
exporter Added table to store multiple newsletters for member (#14408) 2022-04-04 18:11:36 +05:30
importer Replaced white/black list terminology 2022-04-19 11:19:59 +01:00
migrations Mapped subscribers to newsletter (#14518) 2022-04-26 12:31:34 +01:00
schema Added created_at/updated_at to newsletters (#14559) 2022-04-26 12:31:34 +01:00