36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/astaxie/beego/migration"
|
|
)
|
|
|
|
// DO NOT MODIFY
|
|
type Post_20181114_181919 struct {
|
|
migration.Migration
|
|
}
|
|
|
|
// DO NOT MODIFY
|
|
func init() {
|
|
m := &Post_20181114_181919{}
|
|
m.Created = "20181114_181919"
|
|
|
|
migration.Register("Post_20181114_181919", m)
|
|
}
|
|
|
|
// Run the migrations
|
|
func (m *Post_20181114_181919) Up() {
|
|
// use m.SQL("CREATE TABLE ...") to make schema update
|
|
m.SQL("CREATE TABLE public.post ( id integer NOT NULL, name text, data text NOT NULL, meta jsonb NOT NULL, \"modifiedBy\" bigint 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.post_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;")
|
|
m.SQL("ALTER SEQUENCE public.post_id_seq OWNED BY public.post.id;")
|
|
m.SQL("ALTER TABLE ONLY public.post ALTER COLUMN id SET DEFAULT nextval('public.post_id_seq'::regclass);")
|
|
m.SQL("ALTER TABLE ONLY public.post ADD CONSTRAINT post_pkey PRIMARY KEY (id);")
|
|
}
|
|
|
|
// Reverse the migrations
|
|
func (m *Post_20181114_181919) Down() {
|
|
// use m.SQL("DROP TABLE ...") to reverse schema update
|
|
m.SQL("DROP TABLE public.post;")
|
|
|
|
}
|