multitenantStack/database/migrations/20181114_181923_contact.go

36 lines
1.3 KiB
Go
Raw Normal View History

2018-11-14 17:34:03 +00:00
package main
import (
"github.com/astaxie/beego/migration"
)
// DO NOT MODIFY
type Contact_20181114_181923 struct {
migration.Migration
}
// DO NOT MODIFY
func init() {
m := &Contact_20181114_181923{}
m.Created = "20181114_181923"
migration.Register("Contact_20181114_181923", m)
}
// Run the migrations
func (m *Contact_20181114_181923) Up() {
// use m.SQL("CREATE TABLE ...") to make schema update
m.SQL("CREATE TABLE public.contact ( id integer NOT NULL, \"firstName\" text, \"lastName\" text NOT NULL, \"phoneNumber\" text, email text, \"lastContact\" date, meta jsonb NOT NULL, created timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, modified timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL);")
m.SQL("CREATE SEQUENCE public.contact_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;")
m.SQL("ALTER SEQUENCE public.contact_id_seq OWNED BY public.contact.id;")
m.SQL("ALTER TABLE ONLY public.contact ALTER COLUMN id SET DEFAULT nextval('public.contact_id_seq'::regclass);")
m.SQL("ALTER TABLE ONLY public.contact ADD CONSTRAINT contact_pkey PRIMARY KEY (id);")
}
// Reverse the migrations
func (m *Contact_20181114_181923) Down() {
// use m.SQL("DROP TABLE ...") to reverse schema update
m.SQL("DROP TABLE public.contact;")
}