Skip to content

Junk databases tables schemas #180

@maetx777

Description

@maetx777

Hi!
When I run utility, I will set up --database flag with database name, same from connStr
But, on main.go line 229 you will check database name, otherwise too many schemas collected in the dbTables variable, and when I have some copies of my database (application, application_dev, application_test), names of tables from this databases has conflicts.
See my change:

	var dbTables []string
	// parse or read tables
	if *sqlTable != "" {
		dbTables = strings.Split(*sqlTable, ",")
	} else {
		schemaTables, err := schema.TableNames(db)
		if err != nil {
			fmt.Print(au.Red(fmt.Sprintf("Error in fetching tables information from %s information schema from %s\n", *sqlType, *sqlConnStr)))
			os.Exit(1)
			return
		}
		for _, st := range schemaTables {
			//We need only one database schema <<<
			if st[0] != *sqlDatabase {
				continue
			}
			dbTables = append(dbTables, st[1]) // s[0] == sqlDatabase
		}
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions