Class: Migration
- Inherits:
-
Object
show all
- Defined in:
- lib/yodel/models/core/site/migration.rb
Direct Known Subclasses
APICallModelMigration, DefaultSiteOptionsMigration, EmailModelMigration, GroupModelMigration, LayoutModelMigration, MenuModelMigration, PageModelMigration, RecordModelMigration, RecordProxyPageModelMigration, RedirectPageModelMigration, SearchPageModelMigration, SecurityPageModelsMigration, SnippetModelMigration, UserModelMigration
Class Method Summary
collapse
Class Method Details
.copy_missing_migrations_for_all_sites ⇒ Object
2
3
4
5
6
7
|
# File 'lib/yodel/models/core/site/migration.rb', line 2
def self.copy_missing_migrations_for_all_sites
Site.all.each do |site|
next if site.name == 'yodel'
copy_missing_migrations_for_site(site)
end
end
|
.copy_missing_migrations_for_site(site) ⇒ Object
.inherited(child) ⇒ Object
As migration files are require’d this method will be triggered so we have a reference to the ‘current’ migration class being run
52
53
54
|
# File 'lib/yodel/models/core/site/migration.rb', line 52
def self.inherited(child)
@migration = child
end
|
.run_migrations(site) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/yodel/models/core/site/migration.rb', line 27
def self.run_migrations(site)
Yodel.config.logger.info "Migrating #{site.name}"
each_migration_for(site) do |migration, file|
unless migration.nil?
next if site.migrations.include?(migration.name)
migration.up(site)
site.migrations << migration.name
site.save
site.reload
Yodel.config.logger.info "Migrated #{migration.name}"
else
raise MissingMigration.new(file)
end
end
Yodel.config.logger.info "Migrations for #{site.name} complete"
end
|
.run_migrations_for_all_sites ⇒ Object
21
22
23
24
25
|
# File 'lib/yodel/models/core/site/migration.rb', line 21
def self.run_migrations_for_all_sites
Site.all.each do |site|
run_migrations(site)
end
end
|