Create default roles on `reset` if they don't exist
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- postgresql, typescript
Línea de trabajo
Comienza rastreando el flujo de reset y los hooks beforeReset y afterReset descritos en el issue, incluido cómo se selecciona el propietario de la base de datos antes de su creación. Determina dónde encajarían los roles predeterminados y los valores de marcador de posición sin requerir que exista la nueva base de datos. La tarea estará terminada cuando reset pueda inicializar de forma fiable los roles requeridos y el comportamiento esté cubierto por pruebas para la configuración inicial y para roles existentes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Feature description
It would be a great developer experience if the Owner and Authenticator roles could be created on reset if they don't already exist. The tool could create the roles automatically or allow developers to do so themselves in hooks.
If the tool handled it automatically, then it could take additional placeholder variables:
{
"placeholders": {
"DATABASE_AUTHENTICATOR": "!ENV",
"DATABASE_AUTHENTICATOR_PASSWORD": "!ENV",
"DATABASE_OWNER_PASSWORD": "!ENV"
// …
}
}
Motivating example
I'm initializing a database for the first time and trying to avoid writing a one-off setup_db.js script by hooking into the graphile-migrate event system.
I tried to create the default roles in an !afterReset.sql script like so:
BEGIN;
DO $$
BEGIN
CREATE ROLE :DATABASE_OWNER WITH LOGIN PASSWORD :DATABASE_OWNER_PASSWORD SUPERUSER;
EXCEPTION WHEN duplicate_object THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE;
END;
$$;
DO $$
BEGIN
CREATE ROLE :DATABASE_AUTHENTICATOR WITH LOGIN PASSWORD :DATABASE_AUTHENTICATOR_PASSWORD NOINHERIT;
EXCEPTION WHEN duplicate_object THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE;
END
$$;
…
However, this fails because graphile-migrate attempts to run the script as the Owner before the Owner is created:
graphile-migrate: dropped database 'my_database'
Error: Failed to create database 'my_database' with owner 'my_database_owner': role "my_database_owner" does not exist
I was surprised by the error because I expected graphile-migrate to connect as the root user.
Alternatively, I tried creating the default roles in a !beforeReset.sql script. However, this fails because the beforeReset hook expects the database to exist before it's been created:
error: database "my_database" does not exist
Creating these roles is something all graphile-migrate users have to do, so all of us could benefit from this feature 😄.
Breaking changes
I don't think so.
Supporting development
I [tick all that apply]:
- am interested in building this feature myself
- am interested in collaborating on building this feature
- am willing to help testing this feature before it's released
- am willing to write a test-driven test suite for this feature (before it exists)
- am a Graphile sponsor ❤️
- have an active support or consultancy contract with Graphile
- Lenguaje dominante
- TypeScript
- Estrellas
- 836
- Forks
- 71
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de graphile/migrate
-
Partition migrations folderAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 45/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
-
🐛 bug
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
Todos los issues de graphile/migrate
Issues similares
-
foreground-up-signals-live: delivery-repair cell expects a spawn suggestion status no longer printsAbiertobug triage:owned
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
e2e-failure ready-to-code
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
redhat-developer/rhdh-plugin-export-overlays#4905 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
directus/directus#28558 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
review: medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
1lck/Lithe-IDEA#2432 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
cloudflare/workers-sdk#17189 ·
Los mantenedores suelen responder en 1 día