spec/zdm_spec.rb in zdm-1.0.6 vs spec/zdm_spec.rb in zdm-1.0.7

- old
+ new

@@ -34,10 +34,13 @@ it 'migrates live tables' do Zdm.change_table(:people) do |m| m.alter("DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci") m.add_column('test', "varchar(32) DEFAULT 'foo'") m.change_column('name', 'varchar(99) NOT NULL') + m.remove_index('index_people_on_created_at') + m.add_index(:code) + m.add_index([:created_at, :code], unique: true, name: 'idx_test', length: {code: 191}) end conn = ActiveRecord::Base.connection stmt = conn.select_rows('show create table people')[0][1] expect(stmt.squish).to eq(<<-EOS.squish) @@ -48,12 +51,13 @@ `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` datetime DEFAULT NULL, `test` varchar(32) COLLATE utf8_unicode_ci DEFAULT 'foo', PRIMARY KEY (`id`), UNIQUE KEY `index_people_on_name` (`name`) USING BTREE, + UNIQUE KEY `idx_test` (`created_at`,`code`(191)) USING BTREE, KEY `index_people_on_account_id_and_code` (`account_id`,`code`(191)) USING BTREE, - KEY `index_people_on_created_at` (`created_at`) USING BTREE + KEY `index_people_on_code` (`code`(191)) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci EOS archive_tables = conn.send(Zdm.tables_method).select { |name| name.starts_with?('zdma_') } expect(archive_tables.length).to eq(1) @@ -80,13 +84,15 @@ CREATE TABLE `people` ( `id` int(11) NOT NULL AUTO_INCREMENT, `account_id` int(11) DEFAULT NULL, `name` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `created_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), + `created_at` datetime DEFAULT NULL, + PRIMARY KEY (`id`), UNIQUE KEY `index_people_on_name` (`name`) USING BTREE, + UNIQUE KEY `idx_test` (`created_at`,`code`(191)) USING BTREE, KEY `index_people_on_account_id_and_code` (`account_id`,`code`(191)) USING BTREE, - KEY `index_people_on_created_at` (`created_at`) USING BTREE + KEY `index_people_on_code` (`code`(191)) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci EOS archive_tables = conn.send(Zdm.tables_method).select { |name| name.starts_with?('zdma_') } expect(archive_tables.length).to eq(2) \ No newline at end of file