Class: Yrby::Generators::TablesGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Yrby::Generators::TablesGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/yrby/tables/tables_generator.rb
Overview
bin/rails generate yrby:tables — the migration for the gem-owned
document models (Y::Document + Y::DocumentUpdate). Invoked by
yrby:install, and by other gems building on the same storage.
Template notes (kept here, not in the emitted migration): state is 4.gigabytes - 1 (longblob on MySQL — a compacted snapshot is the whole document; a 16 MB cap would break compaction) and payload is 16.megabytes - 1 (one update can carry a big paste or a client's accumulated offline edits — the 64 KB default blob is too small). The partial unique index's WHERE only keeps key-only rows out of the index: uniqueness holds without it, since unique indexes treat NULLs as distinct on every supported database, and MySQL drops the predicate harmlessly. y_document_updates indexes (document_id, pending) instead of bare document_id: the prefix serves the tail and foreign-key lookups, and the pair serves the clean-row count every append runs.
Instance Method Summary collapse
Instance Method Details
#create_migration_file ⇒ Object
29 30 31 32 |
# File 'lib/generators/yrby/tables/tables_generator.rb', line 29 def create_migration_file migration_template "create_y_tables.rb", File.join(db_migrate_path, "create_y_tables.rb") end |