{"id":35003987,"url":"https://github.com/mayur-tolexo/pg-shifter","last_synced_at":"2026-05-05T01:31:38.307Z","repository":{"id":57572683,"uuid":"210032842","full_name":"mayur-tolexo/pg-shifter","owner":"mayur-tolexo","description":"Golang struct to postgres table shifter.","archived":false,"fork":false,"pushed_at":"2020-05-04T13:41:18.000Z","size":277,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-20T06:32:40.390Z","etag":null,"topics":["database","migration","migrator","postgresql"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mayur-tolexo.png","metadata":{"files":{"readme":"README.md","changelog":"historyTable.go","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-21T18:14:19.000Z","updated_at":"2021-03-22T10:08:43.000Z","dependencies_parsed_at":"2022-08-24T12:43:06.983Z","dependency_job_id":null,"html_url":"https://github.com/mayur-tolexo/pg-shifter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mayur-tolexo/pg-shifter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayur-tolexo%2Fpg-shifter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayur-tolexo%2Fpg-shifter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayur-tolexo%2Fpg-shifter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayur-tolexo%2Fpg-shifter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mayur-tolexo","download_url":"https://codeload.github.com/mayur-tolexo/pg-shifter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayur-tolexo%2Fpg-shifter/sbom","scorecard":{"id":630487,"data":{"date":"2025-08-11","repo":{"name":"github.com/mayur-tolexo/pg-shifter","commit":"b5dfc24c97f4dbae9a99d84fcc7cd30b0bd4c68f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T07:47:24.309Z","repository_id":57572683,"created_at":"2025-08-21T07:47:24.309Z","updated_at":"2025-08-21T07:47:24.309Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32632103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","migration","migrator","postgresql"],"created_at":"2025-12-27T04:25:31.719Z","updated_at":"2026-05-05T01:31:38.300Z","avatar_url":"https://github.com/mayur-tolexo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Godocs](https://img.shields.io/badge/golang-documentation-blue.svg)](https://www.godoc.org/github.com/mayur-tolexo/pg-shifter)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mayur-tolexo/pg-shifter)](https://goreportcard.com/report/github.com/mayur-tolexo/pg-shifter)\n[![Open Source Helpers](https://www.codetriage.com/mayur-tolexo/sworker/badges/users.svg)](https://www.codetriage.com/mayur-tolexo/pg-shifter)\n[![Release](https://img.shields.io/github/release/mayur-tolexo/sworker.svg?style=flat-square)](https://github.com/mayur-tolexo/pg-shifter/releases)\n\n# pg-shifter\nGolang struct to postgres table shifter. go1.9+ required.  \n\nThe main objective is to keep the table's complete schema details in golang table struct only.  \nIf any column is missing is struct which is their in the database table then that column will be dropped.  \nIf any column is extra in struct which is not their in the database table then that column will be added.  \nIf any modification in column type/constraint in struct which is not matching with database then that will be modified.  \nSo, to make sure that your go table struct tells you the actual schema of table and to make alter easy we have created this migrator.  \n\nYou are most welcome to contribute :)  \n\n## Install\n1. go get github.com/mayur-tolexo/pg-shifter\n1. go get github.com/tools/godep\n1. cd $GOPATH/src/github.com/mayur-tolexo/pg-shifter/\n1. godep restore -v\n\n## Features\n1. [Create Table](#create-table)\n2. [Create Enum](#create-enum)\n3. [Upsert Enum](#upsert-enum)\n4. [Create Index](#create-index)\n5. [Create Unique Key](#create-unique-key)\n6. [Upsert Unique Key](#upsert-unique-key)\n7. [Create All Tables](#create-all-tables)\n6. [Alter Table](#alter-table)\n6. [Alter All Tables](#alter-all-tables)\n6. [Drop Table](#drop-table)\n6. [Drop All Tables](#drop-all-tables)\n8. [Create Table Struct](#create-table-struct)\n8. Create history table\n8. Add trigger\n\n## Alter table supported operations:\n1. [Add New Column](#add-new-column)\n2. [Remove existing column](#remove-existing-column)\n3. Modify existing column\n\t1. Modify datatype\n\t2. Modify data length (e.g. varchar(255) to varchar(100))\n\t3. Add/Drop default value\n\t4. Add/Drop Not Null Constraint\n\t5. Add/Drop constraint (Unique/Foreign Key)\n\t6. Modify constraint\n\t\t1. Set constraint deferrable\n\t\t\t1. Initially deferred\n\t\t\t1. Initially immediate\n\t\t2. Set constraint not deferrable\n\t\t3. Add/Drop FOREIGN KEY **ON DELETE** DEFAULT/NO ACTION/RESTRICT/CASCADE/SET NULL\n\t\t4. Add/Drop FOREIGN KEY **ON UPDATE** DEFAULT/NO ACTION/RESTRICT/CASCADE/SET NULL\n\n## Create Table\n__CreateTable(conn *pg.DB, model interface{}) (err error)__  \n\nThis will create table if not exists from go struct.\nAlso, if any enum associated to the table struct then that will be created as well.  \nAll the unique keys and index associated to the table struct will be created as well.\n```\ni) Directly passing struct model  \nii) Passing table name after setting model  \n```\n\n##### i) Directly passing struct model\n```\ntype TestAddress struct {\n\ttableName struct{} `sql:\"test_address\"`\n\tAddressID int      `sql:\"address_id,type:serial NOT NULL PRIMARY KEY\"`\n\tAddress   string   `sql:\"address,type:text\"`\n\tCity      string   `sql:\"city,type:varchar(25) NULL\"`\n}\n\ns := shifter.NewShifter()\nerr := s.CreateTable(conn, \u0026TestAddress{})\n```\n##### ii) Passing table name after setting model\n```\ns := shifter.NewShifter()\ns.SetTableModel(\u0026TestAddress{})\nerr := s.CreateTable(conn, \"test_address\")\n```\n\n## Create Enum\n__CreateAllEnum(conn *pg.DB, model interface{}) (err error)__   \n\nThis will create all the enum associated to the given table.  \nTo define enum on table struct you need to create a method with following signature:  \n```\nfunc (tableStruct) Enum() map[string][]string\n```\nHere returned map's key is enum name and value is slice of enum values.  \nIf enum already exist in database then it will not create enum again.\n```\ni) Directly passing struct model   \nii) Passing table name after setting model  \n```\n\n##### i) Directly passing struct model\n```\ntype TestAddress struct {\n\ttableName struct{} `sql:\"test_address\"`\n\tAddressID int      `sql:\"address_id,type:serial NOT NULL PRIMARY KEY\"`\n\tAddress   string   `sql:\"address,type:text\"`\n\tCity      string   `sql:\"city,type:varchar(25) NULL\"`\n\tStatus    string   `sql:\"status,type:address_status\"`\n}\n\n//Enum of the table.\nfunc (TestAddress) Enum() map[string][]string {\n\tenm := map[string][]string{\n\t\t\"address_status\": {\"enable\", \"disable\"},\n\t}\n\treturn enm\n}\n\ns := shifter.NewShifter()\nerr := s.CreateAllEnum(conn, \u0026TestAddress{})\n```\n##### ii) Passing table name after setting model\n```\ns := shifter.NewShifter()\ns.SetTableModel(\u0026TestAddress{})\nerr = s.CreateAllEnum(conn, \"test_address\")\n```\n\n---------------\n\n__CreateEnum(conn *pg.DB, model interface{}, enumName string) (err error)__  \n\nThis will create given enum if associated to given table  \n```\ni) Directly passing struct model   \nii) Passing table name after setting model  \n```\n\n##### i) Directly passing struct model\n```\ns := shifter.NewShifter()\nerr := s.CreateEnum(conn, \u0026TestAddress{}, \"address_status\")\n```\n##### ii) Passing table name after setting model\n```\ns := shifter.NewShifter()\ns.SetTableModel(\u0026TestAddress{})\nerr = s.CreateEnum(conn, \"test_address\", \"address_status\")\n```\n\n\n## Upsert Enum\n__UpsertAllEnum(conn *pg.DB, model interface{}) (err error)__   \n\nThis will create/update all the enum associated to the given table.\nTo define enum on table struct you need to create a method with following signature:  \n```\nfunc (tableStruct) Enum() map[string][]string\n```\nHere returned map's key is enum name and value is slice of enum values.  \nIf enum already exist in database then it will update the enum value which are missing in the database.\n\n```\ni) Directly passing struct model   \nii) Passing table name after setting model  \n```\n\n##### i) Directly passing struct model\n```\ntype TestAddress struct {\n\ttableName struct{} `sql:\"test_address\"`\n\tAddressID int      `sql:\"address_id,type:serial NOT NULL PRIMARY KEY\"`\n\tAddress   string   `sql:\"address,type:text\"`\n\tCity      string   `sql:\"city,type:varchar(25) NULL\"`\n\tStatus    string   `sql:\"status,type:address_status\"`\n}\n\n//Enum of the table.\nfunc (TestAddress) Enum() map[string][]string {\n\tenm := map[string][]string{\n\t\t\"address_status\": {\"enable\", \"disable\"},\n\t}\n\treturn enm\n}\n\ns := shifter.NewShifter()\nerr := s.UpsertAllEnum(conn, \u0026TestAddress{})\n```\n##### ii) Passing table name after setting model\n```\ns := shifter.NewShifter()\ns.SetTableModel(\u0026TestAddress{})\nerr = s.UpsertAllEnum(conn, \"test_address\")\n```\n\n---------------\n\n__UpsertEnum(conn *pg.DB, model interface{}, enumName string) (err error)__  \n\nThis will create/update given enum if associated to given table  \n```\ni) Directly passing struct model   \nii) Passing table name after setting model  \n```\n\n##### i) Directly passing struct model\n```\ns := shifter.NewShifter()\nerr := s.UpsertEnum(conn, \u0026TestAddress{}, \"address_status\")\n```\n##### ii) Passing table name after setting model\n```\ns := shifter.NewShifter()\ns.SetTableModel(\u0026TestAddress{})\nerr = s.UpsertEnum(conn, \"test_address\", \"address_status\")\n```\n\n\n## Create Index\n__CreateAllIndex(conn *pg.DB, model interface{}, skipPrompt ...bool) (err error)__   \n\nThis will create all the index associated to the given table.  \nIf __skipPrompt__ is enabled then it won't ask for confirmation before creating index. Default is disable.  \nTo define index on table struct you need to create a method with following signature:  \n```\nfunc (tableStruct) Index() map[string]string  \n```\nHere returned map's key is column which need to index and value is the type of data structure to user for indexing. Default is btree. For composite index you can add column comma seperated.\n```\ni) Directly passing struct model   \nii) Passing table name after setting model  \n```\n\n##### i) Directly passing struct model\n```\ntype TestAddress struct {\n\ttableName struct{}    `sql:\"test_address\"`\n\tAddressID int         `json:\"address_id,omitempty\" sql:\"address_id,type:serial PRIMARY KEY\"`\n\tCity      string      `json:\"city\" sql:\"city,type:varchar(25) UNIQUE\"`\n\tStatus    string      `json:\"status,omitempty\" sql:\"status,type:address_status\"`\n\tInfo      interface{} `sql:\"info,type:jsonb\"`\n}\n\n//Index of the table. For composite index use ,\n//Default index type is btree. For gin index use gin\nfunc (TestAddress) Index() map[string]string {\n\tidx := map[string]string{\n\t\t\"status\":            shifter.BtreeIndex,\n\t\t\"info\":              shifter.GinIndex,\n\t\t\"address_id,status\": shifter.BtreeIndex,\n\t}\n\treturn idx\n}\n\ns := shifter.NewShifter()\nerr := s.CreateAllIndex(conn, \u0026TestAddress{})\n```\n##### ii) Passing table name after setting model\n```\ns := shifter.NewShifter()\ns.SetTableModel(\u0026TestAddress{})\nerr = s.CreateAllIndex(conn, \"test_address\")\n```\n\n\n## Create Unique Key\n__CreateAllUniqueKey(conn *pg.DB, model interface{}, skipPrompt ...bool) (err error)__   \n\nThis will create all the composite unique key associated to the given table.  \nIf __skipPrompt__ is enabled then it won't ask for confirmation before creating unique key. Default is disable.  \nTo define composite unique key on table struct you need to create a method with following signature:  \n```\nfunc (tableStruct) UniqueKey() []string\n```\nHere returned slice is the columns comma seperated.  \nIf single column need to create unique key then use UNIQUE sql tag for column.  \n```\ni) Directly passing struct model   \nii) Passing table name after setting model  \n```\n\n##### i) Directly passing struct model\n```\ntype TestAddress struct {\n\ttableName struct{}  `sql:\"test_address\"`\n\tAddressID int       `json:\"address_id,omitempty\" sql:\"address_id,type:serial PRIMARY KEY\"`\n\tCity      string    `json:\"city\" sql:\"city,type:varchar(25) UNIQUE\"`\n\tStatus    string    `json:\"status,omitempty\"\n}\n\n//UniqueKey of the table. This is for composite unique keys\nfunc (TestAddress) UniqueKey() []string {\n\tuk := []string{\n\t\t\"address_id,status,city\",\n\t}\n\treturn uk\n}\n\ns := shifter.NewShifter()\nerr := s.CreateAllUniqueKey(conn, \u0026TestAddress{})\n```\n##### ii) Passing table name after setting model\n```\ns := shifter.NewShifter()\ns.SetTableModel(\u0026TestAddress{})\nerr = s.CreateAllUniqueKey(conn, \"test_address\")\n```\n\n## Upsert Unique Key\n__UpsertAllUniqueKey(conn *pg.DB, model interface{}, skipPrompt ...bool) (err error)__   \n\nThis will create all the composite unique key associated to the given table.  \nModify composite unique key which are not matching with table and struct.  \nDrop composite unique key which exists in table but not in struct.  \nIf __skipPrompt__ is enabled then it won't ask for confirmation before upserting unique key. Default is disable.  \nTo define composite unique key on table struct you need to create a method with following signature:  \n```\nfunc (tableStruct) UniqueKey() []string\n```\nHere returned slice is the columns comma seperated.  \nIf single column need to create unique key then use UNIQUE sql tag for column.  \n```\ni) Directly passing struct model   \nii) Passing table name after setting model  \n```\n\n##### i) Directly passing struct model\n```\ntype TestAddress struct {\n\ttableName struct{}  `sql:\"test_address\"`\n\tAddressID int       `json:\"address_id,omitempty\" sql:\"address_id,type:serial PRIMARY KEY\"`\n\tCity      string    `json:\"city\" sql:\"city,type:varchar(25) UNIQUE\"`\n\tStatus    string    `json:\"status,omitempty\"\n}\n\n//UniqueKey of the table. This is for composite unique keys\nfunc (TestAddress) UniqueKey() []string {\n\tuk := []string{\n\t\t\"address_id,status,city\",\n\t}\n\treturn uk\n}\n\ns := shifter.NewShifter()\nerr := s.UpsertAllUniqueKey(conn, \u0026TestAddress{})\n```\n##### ii) Passing table name after setting model\n```\ns := shifter.NewShifter()\ns.SetTableModel(\u0026TestAddress{})\nerr = s.UpsertAllUniqueKey(conn, \"test_address\")\n```\n\n\n## Create All Tables\n__CreateAllTable(conn *pg.DB) (err error)__  \n\nThis will create table if not exists from go struct which are set in shifter.\nAlso, if any enum associated to the table struct then that will be created as well.  \nAll the unique keys and index associated to the table struct will be created as well.\n```\ndb := []interface{}{\u0026TestAddress{}, \u0026TestUser{}, \u0026TestAdminUser{}}\n\ns := shifter.NewShifter()\ns.SetTableModels(db)\nerr := s.CreateAllTable(conn)\n```\n\n\n## Alter Table\n__AlterTable(conn *pg.DB, model interface{}, skipPrompt ...bool) (err error)__   \n\nThis will alter table.  \nIf __skipPrompt__ is enabled then it won't ask for confirmation before upserting unique key. Default is disable.  \n```\ni) Directly passing struct model   \nii) Passing table name after setting model  \n```\n\n##### i) Directly passing struct model\n```\ntype TestAddress struct {\n\ttableName struct{}  `sql:\"test_address\"`\n\tAddressID int       `json:\"address_id,omitempty\" sql:\"address_id,type:serial PRIMARY KEY\"`\n\tCity      string    `json:\"city\" sql:\"city,type:varchar(25) UNIQUE\"`\n\tStatus    string    `json:\"status,omitempty\"\n}\n\ns := shifter.NewShifter()\nerr := s.AlterTable(conn, \u0026TestAddress{})\n```\n##### ii) Passing table name after setting model\n```\ns := shifter.NewShifter()\ns.SetTableModel(\u0026TestAddress{})\nerr = s.AlterTable(conn, \"test_address\")\n```\n\n## Alter All Tables\n__AlterAllTable(conn *pg.DB, skipPrompt ...bool) (err error)__  \nThis will alter all tables added in shifter using SetTableModels().    \nIf __skipPrompt__ is enabled then it won't ask for confirmation before upserting unique key. Default is disable.  \n\n\n```\ndb := []interface{}{\u0026TestAddress{}, \u0026TestUser{}, \u0026TestAdminUser{}}\n\ns := shifter.NewShifter()\ns.SetTableModels(db)\nerr := s.AlterAllTable(conn)\n```\n\n## Drop Table\n__DropTable(conn *pg.DB, model interface{}, cascade bool) (err error)__  \n\nThis will drop the table from database if exists. Also, if history table associated to this table exists then that will be dropped as well.\nIf cascade is true then it will drop table with cascade.\n\n##### i) Directly passing struct model\n```\ns := shifter.NewShifter()\nerr := s.DropTable(conn, \u0026TestAddress{}, true)\n```\n\n##### ii) Passing table name\n```\ns := shifter.NewShifter()\nerr := s.DropTable(conn, \"test_address\", true)\n```\n\n## Drop All Tables\n__DropAllTable(conn *pg.DB, cascade bool) (err error)__  \n\nThis will drop all the table from database if exists which are set in shifter. So, before calling it you need to SetTableModels() on shifter.\nAlso, if history table associated to this table exists then that will be dropped as well.\nIf cascade is true then it will drop tables with cascade.\n\n```\ndb := []interface{}{\u0026TestAddress{}, \u0026TestUser{}, \u0026TestAdminUser{}}\n\ns := shifter.NewShifter()\ns.SetTableModels(db)\nerr := s.DropAllTable(conn, true)\n```\n\n\n## Create Table Struct\nCreateStruct(conn *pg.DB, tableName string, filePath string) (err error)\n```\nif conn, err := psql.Conn(true); err == nil {\n\tshifter.NewShifter().CreateStruct(conn, \"address\", \"\")\n}\n```\n#### OUTPUT\n![Screenshot 2019-12-08 at 10 09 43 PM](https://user-images.githubusercontent.com/20511920/70392617-db073f80-1a07-11ea-856c-cf83247db3dd.png)\n\n\n\n## Add New Column\nJust add new field in the table struct and run AlterTable().  \n\n## Remove Existing Column\nRemove field from the table struct which you want to remove and run AlterTable().  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayur-tolexo%2Fpg-shifter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmayur-tolexo%2Fpg-shifter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayur-tolexo%2Fpg-shifter/lists"}