-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom baseline sql script #2578
Comments
Hello @KostyaZgara, the PG extension was supported in the canary version of the atlas, which you can install using our install script. Check more information about it here: https://atlasgo.io/atlas-schema/hcl#extension Please let me know it you still have issue with PG extension, cheers! |
Hi, thanks for your response! I tried to follow the documentation you sent me, but atlas doesn't see any changes between current migration directory and the desired state. I added extension resource to schema file extension "postgis" {
schema = schema.public
comment = "PostGIS geometry and geography spatial types and functions"
}
schema "public" {
comment = "standard public schema"
} Run command $ atlas migrate diff --env moji install_postgis_extension which gave me the following message
But I expected that Atlas would generate a new migration entry with something like
Here is my Atlas CLI version
|
In general your local database container should have the same state of your production database so versioned migrations are valid. I think what you can do is instead of using postgis locally, use bare postgres (if that is what you have in production). Then Atlas will generate the Another idea I can think of is maybe to use a baseline schema in the postgis docker container locally where you disable the extension. For the diuff computation Atlas will then generate a |
I don't fully understand how extension resources work. For instance, this postgres image https://hub.docker.com/r/bitnami/postgresql has postgis installed on server, but it's not enabled by default, and executing Theoretically, I can narrow down my image types to one when postgis is installed, but not enabled, cuz for example, for production I'm using GCP CloudSQL which seems to have postgis installed, but not enabled (I can't verify it for sure, cuz I'm blocked by issue where I can't push migrations to Atlas Cloud), but my research gave me that vast majority of cloud database has postgis onboard out-of-box. So let's say I would use for CI, local development, and dev database a similar image where postgis is installed, but not enabled, for instance, bitname image. But how atlas resource While writing this message, I realized I never tried to use bitnami image everywhere except production. Let me try to do it and I'll come back with the results |
Please see my comment here. |
Thanks! The solution of using Atlas on the database level instead of schema worked for me. Here is my feedback comment #2596 |
Hi there! I'm looking for something like a custom baseline SQL script that I can define in my
atlas.hcl
config. Here is what I meanBut seems the current
baseline
parameter undermigration
block expects the baseline version instead of the script like in the docker driver. The problem is that I have different databases in CI and in the cloud, where the cloud database has an extension on the server, but is not initialized, so I have to create a new migration version to run the statementcreate extension postgis;
, but in the CI I use postgis docker container which initializes postgis extension by default https://github.com/postgis/docker-postgis/blob/master/initdb-postgis.sh and that seems impossible to disable. So, to prevent failing my statementcreate extension
in the CI, I have to drop that extension first and let my migrations initialize the extension again. I managed to get this work in dev database by providing a custom SQL script for baseline, but I failed to do it on my primary database. The current workaround I drop the extension in the CI before applying atlas migrations, but it seems relevant to let users define custom baseline script per environment without modifying the CI itself. If you have other options on how I can get this thing to work fully on Atlas, I will be happy to hear! Thanks!The text was updated successfully, but these errors were encountered: