Skip to content

TERRA-114 ⁃ Support table definitions from CREATE statements #239

Open
@SpencerC

Description

@SpencerC

The current approach requires describing table schemas through a bespoke representation. I'd wager most clients with explicit schemas have them defined in CREATE statement form.

Current Approach

resource "astra_database" "dev" {
  name           = "puppies"
  keyspace       = "puppies"
  cloud_provider = "gcp"
  regions        = ["us-east1"]
}
resource "astra_table" "table-1" {
  table       = "mytable"
  keyspace = "puppies"
  database_id = astra_database.dev.id
  region = "us-east1"
  clustering_columns = "a:b"
  partition_keys = "c:d"
  column_definitions= [
    {
      Name: "a"
      Static: false
      TypeDefinition: "text"
    },
    {
      Name: "b"
      Static: false
      TypeDefinition: "text"
    },
    ...
  ]
} 

Proposed Approach

environments/prod/main.tf:

resource "astra_database" "dev" {
  name           = "puppies"
  keyspace       = "puppies"
  cloud_provider = "gcp"
  regions        = ["us-east1"]
}
resource "astra_table" "table-1" {
  keyspace = "puppies"
  database_id = astra_database.dev.id
  region = "us-east1"
  schema_path = "../../db/mytable.cql"
} 

db/mytable.cql:

CREATE TABLE mytable
(
    a   TEXT,
    b  TEXT,
    ...
    PRIMARY KEY ((c,d), a, b)
);

┆Issue is synchronized with this Jira Task by Unito
┆Issue Number: TERRA-114
┆Priority: Major

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions