zzh@ZZHPC:/zdata/Github/greenlight$ migrate create -seq -ext=.sql -dir=./migrations create_user_table /zdata/Github/greenlight/migrations/000004_create_user_table.up.sql /zdata/Github/greenlight/migrations/000004_create_user_table.down.sql
CREATE TABLE IF NOT EXISTS user ( id bigserial PRIMARY KEY, created_at timestamp(0) with time zone NOT NULL DEFAULT NOW(), name text NOT NULL, email citext UNIQUE NOT NULL, password_hash bytea NOT NULL, activated bool NOT NULL, version integer NOT NULL DEFAULT 1 );
zzh@ZZHPC:/zdata/Github/greenlight$ make migrate_up migrate -path ./migrations -database "postgres://greenlight:greenlight@localhost/greenlight?sslmode=disable" up error: migration failed: syntax error at or near "user" (column 28) in line 1: CREATE TABLE IF NOT EXISTS user ( id bigserial PRIMARY KEY, created_at timestamp(0) with time zone NOT NULL DEFAULT NOW(), name text NOT NULL, email citext UNIQUE NOT NULL, password_hash bytea NOT NULL, activated bool NOT NULL, version integer NOT NULL DEFAULT 1 ); (details: pq: syntax error at or near "user") make: *** [Makefile:37: migrate_up] Error 1
CANNOT use keyword 'user' as a table name.
zzh@ZZHPC:/zdata/Github/greenlight$ migrate -database $GREENLIGHT_DB_DSN -path ./migrations version 4 (dirty)
zzh@ZZHPC:/zdata/Github/greenlight$ migrate -path ./migrations -database $GREENLIGHT_DB_DSN force 3 zzh@ZZHPC:/zdata/Github/greenlight$ migrate -path ./migrations -database $GREENLIGHT_DB_DSN version 3
Change the table name from 'user' to 'users':
标签:Chapter,12,migrate,Setup,migrations,Github,greenlight,NULL,user From: https://www.cnblogs.com/zhangzhihui/p/18554192