Example #1
0
func (this *NewsTableMigrationScript) GetExecutionContext() *lib.ExecutionContext {
	execContext := lib.NewExecutionContext()
	execContext.AddQueryToApply(lib.NewSimpleSqlInstruction(CREATE_NEWS_TABLE_SQL))
	execContext.AddQueryToRollback(lib.NewSimpleSqlInstruction(DROP_NEWS_TABLE_SQL))
	callback := func() error {
		newsRepo := news.NewNewsRepository(this.conn)
		newsEntity := news.News{
			Title:    "Some news",
			Text:     "Some text",
			AuthorId: 1}
		newsRepo.CreateNews(newsEntity)
		return nil
	}
	execContext.SuccessCallback = callback

	return execContext
}
Example #2
0
func (this *UserTable) GetExecutionContext() *lib.ExecutionContext {
	execContext := lib.NewExecutionContext()
	execContext.AddQueryToApply(lib.NewSimpleSqlInstruction(CREATE_USER_TABLE))
	execContext.AddQueryToRollback(lib.NewSimpleSqlInstruction(DROP_USER_TABLE))
	return execContext
}