ariga / terraform-provider-atlas

Terraform Provider for Atlas
https://atlasgo.io
Apache License 2.0
55 stars 8 forks source link

CGO_ENABLED error on `terraform destroy` #83

Closed adoublef closed 1 year ago

adoublef commented 1 year ago

I am getting the following error when I try to destroy a plan with terraform. I have gcc v12.2.0 installed and I am not using a Go project but a Deno project. below is a snippet of the error

 Error: Atlas Plan Error
│ 
│   with module.iam.atlas_schema.iam,
│   on infra/atlas/main.tf line 15, in resource "atlas_schema" "iam":
│   15: resource "atlas_schema" "iam" {
│ 
│ Unable to connect to database, got error: sqlite: query version pragma:
│ Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to
│ work. This is a stub
giautm commented 1 year ago

Hello, I will checking and updates you soon.

adoublef commented 1 year ago

For sure, if you would like any additional information I can share when needed

adoublef commented 1 year ago

Gentle bump

giautm commented 1 year ago

Hello, @adoublef. can you please try again with the latest version (v0.5.6) and check if it still exists?

If the issue still present, please attach your TF files here.

adoublef commented 1 year ago

Thank you, I will get back soon to see if this still an issue

adoublef commented 1 year ago

I get the following error:

 Error: Atlas Plan Error
│ 
│   with atlas_schema.db,
│   on main.tf line 15, in resource "atlas_schema" "db":
│   15: resource "atlas_schema" "db" {
│ 
│ Unable to generate migration plan, got error: Error: unsupported change
│ *schema.DropSchema

From the TF config

terraform {
  required_providers {
    atlas = {
      source  = "ariga/atlas"
      version = "~> 0.4.5"
    }
  }
}

data "atlas_schema" "db" {
  src     = "file://schema.sql"
  dev_url = "sqlite://file?mode=memory"
}

resource "atlas_schema" "db" {
  hcl     = data.atlas_schema.db.hcl
  url     = "sqlite://file.db"
  dev_url = "sqlite://file?mode=memory"
}

And for completeness here is my table

CREATE TABLE a (
    id INT,
    name TEXT,
    PRIMARY KEY (id)
);

I can see that there was an issue related already regarding dropping.

adoublef commented 1 year ago

I will add that my usecase has been to test with Turso, who currently don't have a provider themselves. I haven't tested with any postgres/mysql databases so unsure if this issue extends there

giautm commented 1 year ago

Yes, the atlas doesn't support drop SQLite schema. Because it's a risk of losing data.

Look like the issue with CGO_ENABLED was gone. So, I'll close this issue. If you still have another issue with the TF-provider or atlas, please fire another one.

Thank you,