當前位置: 首頁>>代碼示例>>Golang>>正文


Golang LimitedTx.Exec方法代碼示例

本文整理匯總了Golang中github.com/BurntSushi/migration.LimitedTx.Exec方法的典型用法代碼示例。如果您正苦於以下問題:Golang LimitedTx.Exec方法的具體用法?Golang LimitedTx.Exec怎麽用?Golang LimitedTx.Exec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/BurntSushi/migration.LimitedTx的用法示例。


在下文中一共展示了LimitedTx.Exec方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: ReplaceBuildEventsIDWithEventID

func ReplaceBuildEventsIDWithEventID(tx migration.LimitedTx) error {
	_, err := tx.Exec(`ALTER TABLE build_events ADD COLUMN event_id integer`)
	if err != nil {
		return err
	}

	startIDs := map[int]int{}

	rows, err := tx.Query(`
		SELECT build_id, min(id)
		FROM build_events
		GROUP BY build_id
	`)
	if err != nil {
		return err
	}

	for rows.Next() {
		var buildID, id int
		err := rows.Scan(&buildID, &id)
		if err != nil {
			return err
		}

		startIDs[buildID] = id
	}

	err = rows.Close()
	if err != nil {
		return err
	}

	for buildID, id := range startIDs {
		_, err := tx.Exec(`
			UPDATE build_events
			SET event_id = id - $2
			WHERE build_id = $1
		`, buildID, id)
		if err != nil {
			return err
		}
	}

	_, err = tx.Exec(`ALTER TABLE build_events DROP COLUMN id`)
	if err != nil {
		return err
	}

	_, err = tx.Exec(`ALTER TABLE build_events ALTER COLUMN event_id SET NOT NULL`)
	if err != nil {
		return err
	}

	_, err = tx.Exec(`CREATE UNIQUE INDEX build_events_build_id_event_id ON build_events (build_id, event_id)`)
	if err != nil {
		return err
	}

	return nil
}
開發者ID:utako,項目名稱:atc,代碼行數:60,代碼來源:12_replace_build_events_id_with_event_id.go

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


注:本文中的github.com/BurntSushi/migration.LimitedTx.Exec方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。