• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang migration.LimitedTx类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/BurntSushi/migration.LimitedTx的典型用法代码示例。如果您正苦于以下问题:Golang LimitedTx类的具体用法?Golang LimitedTx怎么用?Golang LimitedTx使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了LimitedTx类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: AddUserToContainer

func AddUserToContainer(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
	  ALTER TABLE containers
		ADD COLUMN process_user text DEFAULT '';
	`)
	return err
}
开发者ID:xoebus,项目名称:checkin,代码行数:7,代码来源:86_add_user_to_container.go


示例2: initial

func initial(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
    CREATE TABLE pull_requests (
        owner      text NOT NULL,
        repository text NOT NULL,
        sha        text NOT NULL
    );
	`)
	if err != nil {
		return err
	}

	_, err = tx.Exec(`
    CREATE UNIQUE INDEX pull_requests_unique ON pull_requests (
      owner,
      repository,
      sha
    );
	`)
	if err != nil {
		return err
	}

	return nil
}
开发者ID:xoebus,项目名称:checkin,代码行数:25,代码来源:001_initial.go


示例3: AddIndexesToABunchOfStuff

func AddIndexesToABunchOfStuff(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
		CREATE INDEX build_inputs_build_id_versioned_resource_id ON build_inputs (build_id, versioned_resource_id);
	`)
	if err != nil {
		return err
	}

	_, err = tx.Exec(`
		CREATE INDEX build_outputs_build_id_versioned_resource_id ON build_outputs (build_id, versioned_resource_id);
	`)
	if err != nil {
		return err
	}

	_, err = tx.Exec(`
		CREATE INDEX builds_job_id ON builds (job_id);
	`)
	if err != nil {
		return err
	}

	_, err = tx.Exec(`
		CREATE INDEX jobs_pipeline_id ON jobs (pipeline_id);
	`)
	if err != nil {
		return err
	}

	_, err = tx.Exec(`
		CREATE INDEX resources_pipeline_id ON resources (pipeline_id);
	`)

	return nil
}
开发者ID:xoebus,项目名称:checkin,代码行数:35,代码来源:47_add_indexes_to_a_bunch_of_stuff.go


示例4: AddEnvVariablesToContainers

func AddEnvVariablesToContainers(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
		ALTER TABLE containers ADD COLUMN env_variables text NOT NULL DEFAULT '[]';
	`)

	return err
}
开发者ID:ACPK,项目名称:atc,代码行数:7,代码来源:58_add_env_variables_to_containers.go


示例5: RemoveVolumesWithExpiredWorkers

func RemoveVolumesWithExpiredWorkers(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
	DELETE FROM volumes v
	WHERE (SELECT COUNT(name) FROM workers w WHERE w.name = v.worker_name) = 0;
	`)
	return err
}
开发者ID:xoebus,项目名称:checkin,代码行数:7,代码来源:72_remove_volumes_with_expired_workers.go


示例6: createTable

func (d dbVersion) createTable(tx migration.LimitedTx) error {
	_, err := tx.Exec(d.CreateSQL)
	if err == nil {
		err = d.set(tx, 0)
	}
	return err
}
开发者ID:ndlib,项目名称:bendo,代码行数:7,代码来源:db.go


示例7: DefaultRegion

// DefaultRegion will insert a default region into the database with the
// name "default", no start, and no end time.
func (m Migrator) DefaultRegion(tx migration.LimitedTx) error {
	_, err := tx.Exec(
		`INSERT INTO regions(name) VALUES(?)`,
		"default",
	)
	return err
}
开发者ID:andrew-d,项目名称:flypaper,代码行数:9,代码来源:migrate.go


示例8: AddStepLocationToContainers

func AddStepLocationToContainers(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
		ALTER TABLE containers ADD COLUMN step_location integer DEFAULT 0;
	`)

	return err
}
开发者ID:ACPK,项目名称:atc,代码行数:7,代码来源:53_add_step_location_to_containers.go


示例9: MakeVolumesExpiresAtNullable

func MakeVolumesExpiresAtNullable(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
		ALTER TABLE volumes
		ALTER COLUMN expires_at DROP NOT NULL;
	`)
	return err
}
开发者ID:xoebus,项目名称:checkin,代码行数:7,代码来源:65_make_volumes_expires_at_nullable.go


示例10: CascadePipelineDeletes

func CascadePipelineDeletes(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
		ALTER TABLE build_events DROP CONSTRAINT build_events_build_id_fkey;
		ALTER TABLE build_events ADD CONSTRAINT build_events_build_id_fkey FOREIGN KEY (build_id) REFERENCES builds (id) ON DELETE CASCADE;

		ALTER TABLE build_outputs DROP CONSTRAINT build_outputs_build_id_fkey;
		ALTER TABLE build_outputs ADD CONSTRAINT build_outputs_build_id_fkey FOREIGN KEY (build_id) REFERENCES builds(id) ON DELETE CASCADE;

		ALTER TABLE build_outputs DROP CONSTRAINT build_outputs_versioned_resource_id_fkey;
		ALTER TABLE build_outputs ADD CONSTRAINT build_outputs_versioned_resource_id_fkey FOREIGN KEY (versioned_resource_id) REFERENCES versioned_resources(id) ON DELETE CASCADE;

		ALTER TABLE build_inputs DROP CONSTRAINT build_inputs_build_id_fkey;
		ALTER TABLE build_inputs ADD CONSTRAINT build_inputs_build_id_fkey FOREIGN KEY (build_id) REFERENCES builds(id) ON DELETE CASCADE;

		ALTER TABLE build_inputs DROP CONSTRAINT build_inputs_versioned_resource_id_fkey;
		ALTER TABLE build_inputs ADD CONSTRAINT build_inputs_versioned_resource_id_fkey FOREIGN KEY (versioned_resource_id) REFERENCES versioned_resources(id) ON DELETE CASCADE;

		ALTER TABLE jobs_serial_groups DROP CONSTRAINT fkey_job_id;
		ALTER TABLE jobs_serial_groups ADD CONSTRAINT fkey_job_id FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE CASCADE;

		ALTER TABLE builds DROP CONSTRAINT fkey_job_id;
		ALTER TABLE builds ADD CONSTRAINT fkey_job_id FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE CASCADE;

		ALTER TABLE versioned_resources DROP CONSTRAINT fkey_resource_id;
		ALTER TABLE versioned_resources ADD CONSTRAINT fkey_resource_id FOREIGN KEY (resource_id) REFERENCES resources(id) ON DELETE CASCADE;

		ALTER TABLE resources DROP CONSTRAINT resources_pipeline_id_fkey;
		ALTER TABLE resources ADD CONSTRAINT resources_pipeline_id_fkey FOREIGN KEY (pipeline_id) REFERENCES pipelines(id) ON DELETE CASCADE;

		ALTER TABLE jobs DROP CONSTRAINT jobs_pipeline_id_fkey;
		ALTER TABLE jobs ADD CONSTRAINT jobs_pipeline_id_fkey FOREIGN KEY (pipeline_id) REFERENCES pipelines (id) ON DELETE CASCADE;
  `)

	return err
}
开发者ID:pcfdev-forks,项目名称:atc,代码行数:35,代码来源:63_cascade_pipeline_deletes.go


示例11: AddModifiedTimeToBuildInputs

func AddModifiedTimeToBuildInputs(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
		ALTER TABLE build_inputs
		ADD COLUMN modified_time timestamp NOT NULL DEFAULT now();
`)
	return err
}
开发者ID:xoebus,项目名称:checkin,代码行数:7,代码来源:96_add_modified_time_to_build_inputs.go


示例12: CleanUpMassiveUniqueConstraint

func CleanUpMassiveUniqueConstraint(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
		ALTER TABLE containers
		DROP CONSTRAINT IF EXISTS containers_worker_name_resource_id_check_type_check_source__key
	`)
	return err
}
开发者ID:xoebus,项目名称:checkin,代码行数:7,代码来源:79_clean_up_massive_unique_constraint.go


示例13: AddWorkingDirectoryToContainers

func AddWorkingDirectoryToContainers(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
		ALTER TABLE containers ADD COLUMN working_directory text;
	`)

	return err
}
开发者ID:ACPK,项目名称:atc,代码行数:7,代码来源:56_add_working_directory_to_containers.go


示例14: DropCompletedFromBuildPreparation

func DropCompletedFromBuildPreparation(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
	ALTER TABLE build_preparation
	DROP COLUMN completed
	`)
	return err
}
开发者ID:xoebus,项目名称:checkin,代码行数:7,代码来源:82_drop_completed_from_build_preparation.go


示例15: AddCompositeUniqueConstraintToVolumes

func AddCompositeUniqueConstraintToVolumes(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
    ALTER TABLE volumes DROP CONSTRAINT volumes_handle_key;
    ALTER TABLE volumes ADD UNIQUE (worker_name, handle);
	`)

	return err
}
开发者ID:ACPK,项目名称:atc,代码行数:8,代码来源:55_add_composite_unique_constraint_to_volumes.go


示例16: get

func (d dbVersion) get(tx migration.LimitedTx) (int, error) {
	var version int
	r := tx.QueryRow(d.GetSQL)
	if err := r.Scan(&version); err != nil {
		return 0, err
	}
	return version, nil
}
开发者ID:ndlib,项目名称:bendo,代码行数:8,代码来源:db.go


示例17: ResetPendingBuilds

func ResetPendingBuilds(tx migration.LimitedTx) error {
	_, err := tx.Exec(`
	UPDATE builds
	SET scheduled = false
	WHERE scheduled = true AND status = 'pending'
	`)
	return err
}
开发者ID:xoebus,项目名称:checkin,代码行数:8,代码来源:87_reset_pending_builds.go


示例18: RemoveTransitionalCurrentVersions

func RemoveTransitionalCurrentVersions(tx migration.LimitedTx) error {
	_, err := tx.Exec("DROP TABLE transitional_current_versions")
	if err != nil {
		return err
	}

	return nil
}
开发者ID:utako,项目名称:atc,代码行数:8,代码来源:04_remove_transitional_current_versions.go


示例19: AddConfig

func AddConfig(tx migration.LimitedTx) error {
	_, err := tx.Exec(`CREATE TABLE config (config text NOT NULL)`)
	if err != nil {
		return err
	}

	return nil
}
开发者ID:utako,项目名称:atc,代码行数:8,代码来源:14_add_config.go


示例20: AddHijackURLToBuilds

func AddHijackURLToBuilds(tx migration.LimitedTx) error {
	_, err := tx.Exec(`ALTER TABLE builds ADD COLUMN hijack_url varchar(255)`)
	if err != nil {
		return err
	}

	return nil
}
开发者ID:utako,项目名称:atc,代码行数:8,代码来源:07_add_hijack_url_to_builds.go



注:本文中的github.com/BurntSushi/migration.LimitedTx类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang toml.Decode函数代码示例发布时间:2022-05-24
下一篇:
Golang imdb.DB类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap