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


Golang migration.Migration類代碼示例

本文整理匯總了Golang中code/cloudfoundry/org/bbs/migration.Migration的典型用法代碼示例。如果您正苦於以下問題:Golang Migration類的具體用法?Golang Migration怎麽用?Golang Migration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Migration類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: AppendMigration

func AppendMigration(migration migration.Migration) {
	for _, m := range Migrations {
		if m.Version() == migration.Version() {
			panic("cannot have two migrations with the same version")
		}
	}

	Migrations = append(Migrations, migration)
}
開發者ID:cloudfoundry,項目名稱:bbs,代碼行數:9,代碼來源:migrations.go

示例2:

import (
	"encoding/json"
	"time"

	"code.cloudfoundry.org/bbs/db/migrations"
	"code.cloudfoundry.org/bbs/db/sqldb"
	"code.cloudfoundry.org/bbs/migration"
	"code.cloudfoundry.org/clock/fakeclock"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Add Placement Tags to Desired LRPs", func() {
	var (
		mig       migration.Migration
		migErr    error
		fakeClock *fakeclock.FakeClock
	)

	BeforeEach(func() {
		fakeClock = fakeclock.NewFakeClock(time.Now())
		rawSQLDB.Exec("DROP TABLE domains;")
		rawSQLDB.Exec("DROP TABLE tasks;")
		rawSQLDB.Exec("DROP TABLE desired_lrps;")
		rawSQLDB.Exec("DROP TABLE actual_lrps;")

		mig = migrations.NewAddPlacementTagsToDesiredLRPs()
	})

	It("appends itself to the migration list", func() {
		Expect(migrations.Migrations).To(ContainElement(mig))
開發者ID:cloudfoundry,項目名稱:bbs,代碼行數:31,代碼來源:1472757022_add_placement_tags_to_desired_lrp_test.go

示例3:

	"code.cloudfoundry.org/bbs/encryption"
	"code.cloudfoundry.org/bbs/format"
	"code.cloudfoundry.org/bbs/migration"
	"code.cloudfoundry.org/bbs/models"
	"code.cloudfoundry.org/bbs/models/test/model_helpers"
	"code.cloudfoundry.org/lager/lagertest"
	goetcd "github.com/coreos/go-etcd/etcd"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Base 64 Protobuf Encode Migration", func() {
	var (
		migration  migration.Migration
		serializer format.Serializer
		cryptor    encryption.Cryptor

		logger *lagertest.TestLogger
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")

		encryptionKey, err := encryption.NewKey("label", "passphrase")
		Expect(err).NotTo(HaveOccurred())
		keyManager, err := encryption.NewKeyManager(encryptionKey, nil)
		Expect(err).NotTo(HaveOccurred())
		cryptor = encryption.NewCryptor(keyManager, rand.Reader)
		serializer = format.NewSerializer(cryptor)
		migration = migrations.NewBase64ProtobufEncode()
	})
開發者ID:cfibmers,項目名稱:bbs,代碼行數:31,代碼來源:1441411196_base64_protobuf_encode_test.go

示例4:

	"strings"

	"code.cloudfoundry.org/bbs/db/migrations"
	"code.cloudfoundry.org/bbs/db/sqldb"
	"code.cloudfoundry.org/bbs/format"
	"code.cloudfoundry.org/bbs/migration"
	"code.cloudfoundry.org/bbs/test_helpers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Increase Run Info Column Migration", func() {
	if test_helpers.UseSQL() {
		var (
			migration    migration.Migration
			serializer   format.Serializer
			flavor       string
			migrationErr error
		)

		BeforeEach(func() {
			flavor = os.Getenv("USE_SQL")
			rawSQLDB.Exec("DROP TABLE domains;")
			rawSQLDB.Exec("DROP TABLE tasks;")
			rawSQLDB.Exec("DROP TABLE desired_lrps;")
			rawSQLDB.Exec("DROP TABLE actual_lrps;")

			migration = migrations.NewIncreaseRunInfoColumnSize()
			serializer = format.NewSerializer(cryptor)
		})

		It("appends itself to the migration list", func() {
開發者ID:cfibmers,項目名稱:bbs,代碼行數:32,代碼來源:1471030898_increase_run_info_column_test.go

示例5:

	"code.cloudfoundry.org/bbs/db/migrations"
	"code.cloudfoundry.org/bbs/encryption"
	"code.cloudfoundry.org/bbs/format"
	"code.cloudfoundry.org/bbs/migration"
	"code.cloudfoundry.org/bbs/models"
	"code.cloudfoundry.org/bbs/models/test/model_helpers"
	"code.cloudfoundry.org/lager/lagertest"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Change Timeouts to Milliseconds Migration", func() {
	var (
		migration  migration.Migration
		serializer format.Serializer
		cryptor    encryption.Cryptor
		db         *etcddb.ETCDDB

		logger *lagertest.TestLogger
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")

		encryptionKey, err := encryption.NewKey("label", "passphrase")
		Expect(err).NotTo(HaveOccurred())
		keyManager, err := encryption.NewKeyManager(encryptionKey, nil)
		Expect(err).NotTo(HaveOccurred())
		cryptor = encryption.NewCryptor(keyManager, rand.Reader)
		serializer = format.NewSerializer(cryptor)
		migration = migrations.NewTimeoutMilliseconds()
		db = etcddb.NewETCD(format.ENCRYPTED_PROTO, 1, 1, 1*time.Minute, cryptor, storeClient, fakeClock)
開發者ID:cfibmers,項目名稱:bbs,代碼行數:32,代碼來源:1451635200_timeouts_to_milliseconds_test.go

示例6:

package migrations_test

import (
	"code.cloudfoundry.org/bbs/db/migrations"
	"code.cloudfoundry.org/bbs/migration"
	"code.cloudfoundry.org/lager/lagertest"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Add Cache Dependencies Migration", func() {
	var (
		migration migration.Migration
		logger    *lagertest.TestLogger
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")
		migration = migrations.NewAddCachedDependencies()
	})

	It("appends itself to the migration list", func() {
		Expect(migrations.Migrations).To(ContainElement(migration))
	})

	Describe("Version", func() {
		It("returns the timestamp from which it was created", func() {
			Expect(migration.Version()).To(BeEquivalentTo(1450292094))
		})
	})
開發者ID:cfibmers,項目名稱:bbs,代碼行數:30,代碼來源:1450292094_add_cached_dependencies_test.go

示例7:

	"time"

	etcddb "code.cloudfoundry.org/bbs/db/etcd"
	"code.cloudfoundry.org/bbs/db/migrations"
	"code.cloudfoundry.org/bbs/format"
	"code.cloudfoundry.org/bbs/migration"
	"code.cloudfoundry.org/bbs/models"
	"code.cloudfoundry.org/bbs/models/test/model_helpers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("ETCD to SQL Migration", func() {
	var (
		migration    migration.Migration
		serializer   format.Serializer
		migrationErr error
	)

	BeforeEach(func() {
		migration = migrations.NewETCDToSQL()
		serializer = format.NewSerializer(cryptor)

		rawSQLDB.Exec("DROP TABLE domains;")
		rawSQLDB.Exec("DROP TABLE tasks;")
		rawSQLDB.Exec("DROP TABLE desired_lrps;")
		rawSQLDB.Exec("DROP TABLE actual_lrps;")
	})

	It("appends itself to the migration list", func() {
		Expect(migrations.Migrations).To(ContainElement(migration))
開發者ID:cloudfoundry,項目名稱:bbs,代碼行數:31,代碼來源:1461790966_etcd_to_sql_test.go


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