Skip to content

Instantly share code, notes, and snippets.

@winebarrel
Created May 28, 2016 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winebarrel/074b745525f588b28a1499f8a29c3759 to your computer and use it in GitHub Desktop.
Save winebarrel/074b745525f588b28a1499f8a29c3759 to your computer and use it in GitHub Desktop.
ActiveRecord::SchemaMigration Load (0.2ms) SELECT `schema_migrations`.* FROM `schema_migrations`
Migrating to Fix (20160528071947)
(0.1ms) SELECT DATABASE() as db
(0.4ms)
select *
from information_schema.columns
where table_name = 'items'
and table_schema = 'hello_development'
(0.1ms) show create table `items`
(0.2ms)
show indexes from `hello_development`.`items`
where key_name != 'PRIMARY'
(0.1ms) SELECT DATABASE() as db
(0.4ms) show variables like 'version'
(13.1ms) CREATE TABLE `lhmn_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`price` int(11) DEFAULT NULL,
`description` text COLLATE utf8_unicode_ci,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci /* large hadron migration */
(18.6ms) alter table `lhmn_items` add column `arbitrary` INT(12) /* large hadron migration */
(11.1ms) create index `index_items_on_arbitrary` on `lhmn_items` (`arbitrary`) /* large hadron migration */
(24.3ms) alter table lhmn_items add column flag tinyint(1) /* large hadron migration */
(0.5ms)
select *
from information_schema.columns
where table_name = 'lhmn_items'
and table_schema = 'hello_development'
(0.1ms) show create table `lhmn_items`
(0.2ms)
show indexes from `hello_development`.`lhmn_items`
where key_name != 'PRIMARY'
(4.6ms) create trigger `lhmt_del_items`
after delete on `items` for each row
delete ignore from `lhmn_items` /* large hadron migration */
where `lhmn_items`.`id` = OLD.`id` /* large hadron migration */
(4.8ms) create trigger `lhmt_ins_items`
after insert on `items` for each row
replace into `lhmn_items` (`created_at`, `description`, `id`, `name`, `price`, `updated_at`) /* large hadron migration */
values (`NEW`.`created_at`, `NEW`.`description`, `NEW`.`id`, `NEW`.`name`, `NEW`.`price`, `NEW`.`updated_at`) /* large hadron migration */
(4.6ms) create trigger `lhmt_upd_items`
after update on `items` for each row
replace into `lhmn_items` (`created_at`, `description`, `id`, `name`, `price`, `updated_at`) /* large hadron migration */
values (`NEW`.`created_at`, `NEW`.`description`, `NEW`.`id`, `NEW`.`name`, `NEW`.`price`, `NEW`.`updated_at`) /* large hadron migration */
(0.3ms) select min(id) from `items`
(0.1ms) select max(id) from `items`
(22.9ms) rename table `items` to `lhma_2016_05_28_07_31_00_329_items`, `lhmn_items` to `items` /* large hadron migration */
(2.4ms) drop trigger if exists `lhmt_del_items` /* large hadron migration */
(2.4ms) drop trigger if exists `lhmt_ins_items` /* large hadron migration */
(0.4ms) drop trigger if exists `lhmt_upd_items` /* large hadron migration */
(0.1ms) SELECT DATABASE() as db
(0.2ms) show tables
(0.1ms) SELECT DATABASE() as db
(0.3ms) show triggers
(0.1ms) SELECT DATABASE() as db
(5.5ms) drop table if exists lhma_2016_05_28_07_31_00_329_items
(0.2ms) BEGIN
SQL (0.3ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160528071947')
(4.0ms) COMMIT
ActiveRecord::SchemaMigration Load (0.2ms) SELECT `schema_migrations`.* FROM `schema_migrations`
(0.2ms) SELECT fk.referenced_table_name as 'to_table'
,fk.referenced_column_name as 'primary_key'
,fk.column_name as 'column'
,fk.constraint_name as 'name'
FROM information_schema.key_column_usage fk
WHERE fk.referenced_column_name is not null
AND fk.table_schema = 'hello_development'
AND fk.table_name = 'items'
(0.1ms) SHOW CREATE TABLE `items`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment