vereinshaus/pocketbase/pb_migrations/1779230000_align_schema.js
rene 77c6f513b5 Feature: SEPA-Export, Push-Notifications, Onboarding + vollständige UI
- Phosphor Icons (Icon.svelte, svg-Registry)
- Schema-Abgleich: alle Felder zwischen PB-Migrations und types.ts konsistent
- Stripe entfernt, SEPA pain.008 XML-Export implementiert (sepa.ts)
- Beiträge: vollständiges CRUD + SEPA-Einzug-Sheet mit Vorschau
- Termine: vollständiges CRUD (upcoming/vergangen, datetime-local)
- Mitglieder: Formulare um alle Felder erweitert (Adresse, SEPA-Mandat, Notizen)
- Nachrichten: Brevo E-Mail via PocketBase-Hook, UI mit Gruppen-Filter
- Push-Notifications: VAPID, Custom Service Worker (injectManifest),
  Subscribe/Send API-Routen, automatische Subscription nach Login
- Onboarding: 3-Schritt-Flow für neue Vereine, Guard im App-Layout
- Makefile: .env wird vollständig zur DS übertragen
2026-05-20 13:01:11 +02:00

194 lines
7.3 KiB
JavaScript

/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
// vereine: +adresse, +dosb_mitglied; -stripe_customer_id
{
const c = app.findCollectionByNameOrId("pbc_3589557411")
c.fields.removeById("text1888339527") // stripe_customer_id
c.fields.addAt(2, new Field({
"type": "text", "id": "text2001000001", "name": "adresse",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "bool", "id": "bool2001000002", "name": "dosb_mitglied",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false
}))
app.save(c)
}
// gruppen: +beschreibung
{
const c = app.findCollectionByNameOrId("pbc_3099069179")
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000003", "name": "beschreibung",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// mitglieder: +telefon, geburtsdatum, eintrittsdatum, austrittsdatum, strasse, plz, ort, bic, notizen
{
const c = app.findCollectionByNameOrId("pbc_2707111162")
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000010", "name": "telefon",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "date", "id": "date2001000011", "name": "geburtsdatum",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"min": "", "max": ""
}))
c.fields.addAt(99, new Field({
"type": "date", "id": "date2001000012", "name": "eintrittsdatum",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"min": "", "max": ""
}))
c.fields.addAt(99, new Field({
"type": "date", "id": "date2001000013", "name": "austrittsdatum",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"min": "", "max": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000014", "name": "strasse",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000015", "name": "plz",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000016", "name": "ort",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000017", "name": "bic",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000018", "name": "notizen",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// beitraege: +beschreibung; rhythmus +halbjaehrlich (einmalig bleibt)
{
const c = app.findCollectionByNameOrId("pbc_3218207135")
const rhythmus = c.fields.getById("select917011370")
rhythmus.values = ["monatlich", "quartalsweise", "halbjaehrlich", "jaehrlich", "einmalig"]
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000020", "name": "beschreibung",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// einzuege: -stripe_payment_intent_id; status bezahlt→eingezogen
{
const c = app.findCollectionByNameOrId("pbc_659326735")
c.fields.removeById("text4235393406") // stripe_payment_intent_id
const status = c.fields.getById("select2063623452")
status.values = ["ausstehend", "eingezogen", "fehlgeschlagen", "storniert"]
app.save(c)
}
// termine: +beschreibung
{
const c = app.findCollectionByNameOrId("pbc_2279568741")
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000030", "name": "beschreibung",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// nachrichten: +autor_id (relation zu users)
{
const c = app.findCollectionByNameOrId("pbc_1415911511")
c.fields.addAt(2, new Field({
"type": "relation", "id": "relation2001000040", "name": "autor_id",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"cascadeDelete": false, "collectionId": "_pb_users_auth_", "maxSelect": 1, "minSelect": 0
}))
app.save(c)
}
}, (app) => {
// vereine rollback
{
const c = app.findCollectionByNameOrId("pbc_3589557411")
c.fields.removeById("text2001000001")
c.fields.removeById("bool2001000002")
c.fields.addAt(99, new Field({
"type": "text", "id": "text1888339527", "name": "stripe_customer_id",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// gruppen rollback
{
const c = app.findCollectionByNameOrId("pbc_3099069179")
c.fields.removeById("text2001000003")
app.save(c)
}
// mitglieder rollback
{
const c = app.findCollectionByNameOrId("pbc_2707111162")
for (const id of ["text2001000010","date2001000011","date2001000012","date2001000013",
"text2001000014","text2001000015","text2001000016","text2001000017","text2001000018"]) {
c.fields.removeById(id)
}
app.save(c)
}
// beitraege rollback
{
const c = app.findCollectionByNameOrId("pbc_3218207135")
const rhythmus = c.fields.getById("select917011370")
rhythmus.values = ["monatlich", "quartalsweise", "jaehrlich", "einmalig"]
c.fields.removeById("text2001000020")
app.save(c)
}
// einzuege rollback
{
const c = app.findCollectionByNameOrId("pbc_659326735")
const status = c.fields.getById("select2063623452")
status.values = ["ausstehend", "bezahlt", "fehlgeschlagen", "storniert"]
c.fields.addAt(99, new Field({
"type": "text", "id": "text4235393406", "name": "stripe_payment_intent_id",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// termine rollback
{
const c = app.findCollectionByNameOrId("pbc_2279568741")
c.fields.removeById("text2001000030")
app.save(c)
}
// nachrichten rollback
{
const c = app.findCollectionByNameOrId("pbc_1415911511")
c.fields.removeById("relation2001000040")
app.save(c)
}
})