soundcloud / lhm

Online MySQL schema migrations
BSD 3-Clause "New" or "Revised" License
1.83k stars 190 forks source link

Truncate long trigger names #121

Closed sj26 closed 9 years ago

sj26 commented 9 years ago

We are seeing:

==  SomeHorriblyLongMigrationInvolvingTablesWithNamesFarTooLongForHumanBeingsToConsiderReasonable: migrating
I, [2015-07-15T12:07:08.972714 #47706]  INFO -- : Starting LHM run on table=lhmn_tables_with_names_far_too_long_for_human_beings_to_consider
I, [2015-07-15T12:07:08.972868 #47706]  INFO -- : Starting run of class=Lhm::Migrator
I, [2015-07-15T12:07:09.012700 #47706]  INFO -- : Starting run of class=Lhm::Entangler
E, [2015-07-15T12:07:09.015775 #47706] ERROR -- : Error in class=Lhm::Entangler, reverting. exception=ActiveRecord::StatementInvalid message=Mysql2::Error: Identifier name 'lhmt_del_tables_with_names_far_too_long_for_human_beings_to_consider_reasonable' is too long: create trigger `lhmt_del_tables_with_names_far_too_long_for_human_beings_to_consider_reasonable`
...

It looks like this has already been faced in the migrator:

def archive_name
  "lhma_#{ startstamp }_#{ @origin.name }"[0...64]
end

So let's truncate here as well.

sj26 commented 9 years ago

Travis build flakey failed thanks to using Time.now in a spec. That should probably be fixed.

arthurnn commented 9 years ago

Do you mind adding a changelog(https://github.com/soundcloud/lhm/blob/master/CHANGELOG.md) for this fix ? thanks

sj26 commented 9 years ago

@arthurnn done! Sorry for the delay.

arthurnn commented 9 years ago

:heart: thanks