Skip to content
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

merge from master #1

Merged
merged 2 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions database/drivers/mysql/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func parse(log *log.Logger, conn string, schemaNames []string, filterTables func
}
schemas[t.TableSchema] = append(schemas[t.TableSchema], &database.Table{
Name: t.TableName,
Type: t.TableType,
Comment: t.TableComment,
})
}
Expand Down
3 changes: 2 additions & 1 deletion database/drivers/postgres/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func parse(log *log.Logger, conn string, schemaNames []string, filterTables func

schemas[t.TableSchema.String] = append(schemas[t.TableSchema.String], &database.Table{
Name: t.TableName.String,
Type: t.TableType.String,
})
}

Expand Down Expand Up @@ -443,7 +444,7 @@ func queryIndexes(log *log.Logger, db *sql.DB, schemaNames []string) ([]indexRes
const q = `
SELECT
n.nspname as schema,
i.indrelid::regclass as table,
trim(both '"' from i.indrelid::regclass::text) as table,
c.relname as name,
i.indisunique as is_unique,
array_to_string(ARRAY(
Expand Down
1 change: 1 addition & 0 deletions database/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type EnumValue struct {
// Table contains the definition of a database table.
type Table struct {
Name string // the original name of the table in the DB
Type string // the table type (e.g. VIEW or BASE TABLE)
Comment string // the comment attached to the table
Columns []*Column // ordered list of columns in this table
Indexes []*Index // list of indexes in this table
Expand Down
1 change: 1 addition & 0 deletions run/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func makeData(log *log.Logger, info *database.Info, cfg *Config) (*data.DBData,
for _, t := range s.Tables {
table := &data.Table{
DBName: t.Name,
Type: t.Type,
Comment: t.Comment,
Schema: sch,
ColumnsByName: make(map[string]*data.Column, len(t.Columns)),
Expand Down
1 change: 1 addition & 0 deletions run/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Schema struct {
type Table struct {
Name string // the converted name of the table
DBName string // the original name of the table in the DB
Type string // the table type (e.g. VIEW or BASE TABLE)
Comment string // the comment attached to the table
Schema *Schema `yaml:"-" json:"-"` // the schema this table is in
Columns Columns // Database columns
Expand Down
6 changes: 6 additions & 0 deletions run/preview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (dummyDriver) Parse(log *log.Logger, conn string, schemaNames []string, fil
Name: "schema",
Tables: []*database.Table{{
Name: "table",
Type: "BASE TABLE",
Comment: "a table",
Columns: []*database.Column{{
Name: "col1",
Expand Down Expand Up @@ -83,6 +84,7 @@ func (dummyDriver) Parse(log *log.Logger, conn string, schemaNames []string, fil
}},
}, {
Name: "tb2",
Type: "BASE TABLE",
Columns: []*database.Column{{
Name: "col1",
Type: "int",
Expand Down Expand Up @@ -117,6 +119,7 @@ const expectYaml = `schemas:
tables:
- name: abc table
dbname: table
type: BASE TABLE
comment: a table
columns:
- name: abc col1
Expand Down Expand Up @@ -242,6 +245,7 @@ const expectYaml = `schemas:
refcolumndbname: col1
- name: abc tb2
dbname: tb2
type: BASE TABLE
comment: ""
columns:
- name: abc col1
Expand Down Expand Up @@ -398,6 +402,7 @@ var expectJSON = `
{
"Name": "abc table",
"DBName": "table",
"Type": "BASE TABLE",
"Comment": "a table",
"Columns": [
{
Expand Down Expand Up @@ -558,6 +563,7 @@ var expectJSON = `
{
"Name": "abc tb2",
"DBName": "tb2",
"Type": "BASE TABLE",
"Comment": "",
"Columns": [
{
Expand Down