-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parsable DSL for creating and dropping tables
- Loading branch information
Showing
12 changed files
with
97 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package krab | ||
|
||
// DDLCheck constraint DSL for table DDL. | ||
type DDLCheck struct { | ||
Name string `hcl:"name,label"` | ||
Expression string `hcl:"expression"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package krab | ||
|
||
import "github.com/hashicorp/hcl/v2" | ||
|
||
// DDLColumn constraint DSL for table DDL. | ||
type DDLColumn struct { | ||
Name string `hcl:"name,label"` | ||
Type string `hcl:"type,label"` | ||
Null *bool `hcl:"null,optional"` | ||
Identity *DDLIdentity `hcl:"identity,block"` | ||
Default hcl.Expression `hcl:"default,optional"` | ||
Generated *DDLGeneratedColumn `hcl:"generated,block"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package krab | ||
|
||
// DDLCreateTable contains DSL for creating tables. | ||
type DDLCreateTable struct { | ||
Name string `hcl:"name,label"` | ||
Unlogged bool `hcl:"unlogged,optional"` | ||
Columns []*DDLColumn `hcl:"column,block"` | ||
PrimaryKeys []*DDLPrimaryKey `hcl:"primary_key,block"` | ||
ForeignKeys []*DDLForeignKey `hcl:"foreign_key,block"` | ||
Uniques []*DDLUnique `hcl:"unique,block"` | ||
Checks []*DDLCheck `hcl:"check,block"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package krab | ||
|
||
// DDLDropTable contains DSL for dropping tables. | ||
type DDLDropTable struct { | ||
Table string `hcl:"table,label"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package krab | ||
|
||
// DDLForeignKey constraint DSL for table DDL. | ||
type DDLForeignKey struct { | ||
Name string `hcl:"name,label"` | ||
Columns []string `hcl:"columns"` | ||
References DDLReferences `hcl:"references,block"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package krab | ||
|
||
// DDLGeneratedColumn DSL. | ||
type DDLGeneratedColumn struct { | ||
As string `hcl:"as"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package krab | ||
|
||
// DDLIdentity DSL. | ||
type DDLIdentity struct { | ||
Generated string `hcl:"generated,label"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package krab | ||
|
||
// DDLPrimaryKey constraint DSL for table DDL. | ||
type DDLPrimaryKey struct { | ||
Name string `hcl:"name,label"` | ||
Columns []string `hcl:"columns"` | ||
Include []string `hcl:"include,optional"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package krab | ||
|
||
// DDLReferences DSL for ForeignKey. | ||
type DDLReferences struct { | ||
Table string `hcl:"table,label"` | ||
Columns []string `hcl:"columns"` | ||
OnDelete string `hcl:"on_delete,optional"` | ||
OnUpdate string `hcl:"on_update,optional"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package krab | ||
|
||
// DDLUnique constraint DSL for table DDL. | ||
type DDLUnique struct { | ||
Name string `hcl:"name,label"` | ||
Columns []string `hcl:"columns"` | ||
Include []string `hcl:"include,optional"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters