-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
evolve erase
tries to delete citext
type
#253
Comments
Thanks for the feedback. It seems to be a bug when trying to |
I don't depend on this feature as I can just drop the database. No time pressure. Versions
db/V1_0_0__works.sql create extension if not exists pgcrypto;
create domain non_empty_text as text check (value ~ '\S'); vs. db/V1_0_0__bug.sql create extension if not exists citext; test.ps1 Set-StrictMode -Version Latest
$connection="Server=127.0.0.1;Database=test;User Id=postgres;Password=password"
dotnet evolve migrate postgresql -l db -c "$connection"
if (-not $?) { throw "Migrate failed" }
dotnet evolve erase postgresql -c "$connection"
if (-not $?) { throw "Erase failed" } |
I cannot reproduce your issue using evolve create extension if not exists citext WITH SCHEMA ${schema};
create domain ${schema}.non_empty_citext as ${schema}.citext check (value ~ '\S');
create table ${schema}.test (
did integer PRIMARY KEY,
name ${schema}.non_empty_citext
);
insert into ${schema}.test values (1, 'PSG'); And everything works. |
Interesting. I upgraded to create extension if not exists citext; Servers logs When using a schema I found a different issue. This works reliably (migrate then immediately erase): create schema if not exists schema1;
create extension if not exists citext with schema schema1; Running this works for the first execution, but on the second execution migrate fails: create schema if not exists schema1;
create extension if not exists citext with schema schema1;
create domain schema1.non_empty_citext as schema1.citext check (value ~ '\S'); Error
|
Strange. I don't understand why we do not have the same behavior. I use docker alpine latest image in my test. And the same version of Evolve. So ??? Maybe there is some other domain in other schema in your db that use "public"."citext" ? |
Yes, very strange. I did drop and recreate the database after every failure, also using docker postgres:14.1-alpine3.15. Passing the schema as argument eg. create extension citext with schema schema1;
create domain schema1.non_empty_citext as schema1.citext check (value ~ '\S'); Give me a second, I'll try to reproduce in docker compose. |
Note for future readers: this is just a quick hack, please don't write dockerfiles like this (do proper cleanup, copy script files, don't embed connection strings, etc.). Dockerfile FROM debian:11.2-slim
ENV EVOLVE_VERSION="3.1.0-alpha3"
ENV CONNECTION="Server=db;Uid=postgres;Pwd=;Database=postgres"
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates wget libicu67 \
&& wget -q https://github.com/lecaillon/Evolve/releases/download/${EVOLVE_VERSION}/evolve_${EVOLVE_VERSION}_Linux-64bit.tar.gz \
&& tar -xzvf evolve_${EVOLVE_VERSION}_Linux-64bit.tar.gz -C /usr/local/bin --strip-components 1
RUN mkdir db && echo "create extension if not exists citext;" > db/V1_0_0__test.sql
RUN echo "#!/bin/bash" > test.sh \
&& echo "evolve migrate postgresql -l db -c \"${CONNECTION}\"" >> test.sh \
&& echo "evolve erase postgresql -c \"${CONNECTION}\"" >> test.sh
RUN chmod +x test.sh \
&& cat test.sh
ENTRYPOINT [ "./test.sh" ] docker-compose.yml version: "3.9"
services:
db:
image: postgres:14.1-alpine3.15
environment:
POSTGRES_HOST_AUTH_METHOD: trust
evolve:
build: .
links:
- db Run docker compose rm -f
docker compose up --build Output
|
Ok, i reproduce it when no schema is defined, so when the script executes in the schema |
Ok, think I have a fix. I will release it later tomorrow ;) |
Just published Evolve |
The docker compose sample produces Edit: Extensions are not part of a schema, even if create with
Therefore dropping the extensions like evolve is now doing with
Edit2: Dropping extensions globally with |
Ok, my bad. Was sure i had tested it. Unfortunately this cannot be part of my integration tests but I'm gonna try something else. SELECT e.extname
FROM pg_extension e
LEFT JOIN pg_namespace n ON n.oid = e.extnamespace
LEFT JOIN pg_roles r ON r.oid = e.extowner
WHERE n.nspname='{Name}' AND r.rolname=current_user; |
Just published Evolve |
New error, stray double-quote 😁
Interesting, thanks for explaining. I didn't look into postgres users and roles at all yet. I'm still sceptical towards dropping extensions, maybe I'll play around with that later. |
Tired of me ^^ Hopefully the 2nd times I added a new test scenario ... works well apparently :( |
Ok understood why my test was successful... And it explains why deletion of a postgresql extension worked with a schema but doesn't work when associated to public. |
Evolve |
It works! 💪 |
Thanks for your help on this one Peter. And thanks for the Dockerfile you post here and there. It is a very good starting point on how to use Evolve in a Docker pipeline |
I'm creating a domain type based on
citext
Running
evolve erase
fails withNot sure if I'm doing it wrong or this is a bug.
The text was updated successfully, but these errors were encountered: