Class: WatermelonDbSync::Generators::AddSyncFieldsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/watermelon_db_sync/add_sync_fields/add_sync_fields_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Generates the next migration number with a timestamp



17
18
19
# File 'lib/generators/watermelon_db_sync/add_sync_fields/add_sync_fields_generator.rb', line 17

def self.next_migration_number(dirname)
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#copy_migrationsObject



11
12
13
14
# File 'lib/generators/watermelon_db_sync/add_sync_fields/add_sync_fields_generator.rb', line 11

def copy_migrations
  # Use the helper methods directly to set the migration file name and path
  migration_template "add_sync_fields_migration.rb.erb", "db/migrate/#{migration_file_name}.rb"
end

#migration_class_nameObject

Generates the migration class name to use in the template



27
28
29
# File 'lib/generators/watermelon_db_sync/add_sync_fields/add_sync_fields_generator.rb', line 27

def migration_class_name
  "AddSyncFieldsTo#{model_name.tableize.camelize}"
end

#migration_file_nameObject

Generates the migration file name based on the model name



22
23
24
# File 'lib/generators/watermelon_db_sync/add_sync_fields/add_sync_fields_generator.rb', line 22

def migration_file_name
  "add_sync_fields_to_#{model_name.tableize}"
end