bcms_tools 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- 0.0.5
1
+ 0.0.6
2
2
 
data/bcms_tools.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bcms_tools}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["buzzware"]
12
- s.date = %q{2010-02-15}
12
+ s.date = %q{2010-03-01}
13
13
  s.description = %q{Tools for BrowserCms.}
14
14
  s.email = %q{contact@buzzware.com.au}
15
15
  s.extra_rdoc_files = [
@@ -31,6 +31,8 @@ Gem::Specification.new do |s|
31
31
  "lib/bcms_tools/bcms_thumbnails.rb",
32
32
  "lib/bcms_tools/form_helpers.rb",
33
33
  "lib/bcms_tools/form_helpers.rb",
34
+ "lib/bcms_tools/migration_helpers.rb",
35
+ "lib/bcms_tools/migration_helpers.rb",
34
36
  "lib/bcms_tools/view_helpers.rb",
35
37
  "lib/bcms_tools/view_helpers.rb",
36
38
  "lib/bcms_tools_dev.rb",
@@ -0,0 +1,62 @@
1
+ # As of BrowserCMS 3.0.6, on MySQL, tables created by BrowserCMS's custom methods eg. create_content_table
2
+ # default to MyISAM format (Rails defaults to InnoDB).
3
+
4
+ # The following makes InnoDB the default format for tables for browsercms methods
5
+ # that use create_table_from_definition eg. create_content_table and create_versioned_table
6
+ ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
7
+ alias :orig_create_table_from_definition :create_table_from_definition
8
+ def create_table_from_definition(table_name, options, table_definition)
9
+ if !options || !options[:options] || !options[:options].index(/ENGINE/i)
10
+ options ||= {}
11
+ if options[:options]
12
+ options[:options] = options[:options] + "\nENGINE = InnoDB"
13
+ else
14
+ options[:options] = "ENGINE = InnoDB"
15
+ end
16
+ end
17
+ orig_create_table_from_definition(table_name,options,table_definition)
18
+ end
19
+ end
20
+
21
+ module ActiveRecord
22
+ module ConnectionAdapters
23
+ module SchemaStatements
24
+
25
+ #The following methods and migration will convert all
26
+ # MyISAM tables to InnoDB format.
27
+ #
28
+ # Also see https://browsermedia.lighthouseapp.com/projects/28481-browsercms-30/tickets/319-custom-migrations-methods-eg-create_content_table-result-in-myisam-tables
29
+ #
30
+ # example migration :
31
+ #gem 'bcms_tools'; require 'bcms_tools'
32
+ #
33
+ #class ConvertAllToInnodb < ActiveRecord::Migration
34
+ # def self.up
35
+ # convert_database_to_innodb()
36
+ # end
37
+ #
38
+ # def self.down
39
+ # end
40
+ #end
41
+
42
+ def get_isam_tables(aDatabase=nil)
43
+ aDatabase ||= ActiveRecord::Base.connection.current_database
44
+ isam_tables = []
45
+ ActiveRecord::Base.connection.execute("SELECT table_name FROM information_schema.tables WHERE engine = 'MyISAM' and table_schema = '#{aDatabase}';").each {|s| isam_tables << s}
46
+ isam_tables
47
+ end
48
+
49
+ def convert_tables_to_innodb(aTables,aDatabase=nil)
50
+ aDatabase ||= ActiveRecord::Base.connection.current_database
51
+ aTables.each {|t| ActiveRecord::Base.connection.execute("ALTER TABLE #{aDatabase}.#{t} engine=InnoDB;")}
52
+ end
53
+
54
+ # aDatabase may be nil to use the current database
55
+ def convert_database_to_innodb(aDatabase=nil)
56
+ convert_tables_to_innodb(get_isam_tables(aDatabase),aDatabase)
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcms_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - buzzware
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-15 00:00:00 +08:00
12
+ date: 2010-03-01 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -64,6 +64,7 @@ files:
64
64
  - lib/bcms_tools.rb
65
65
  - lib/bcms_tools/bcms_thumbnails.rb
66
66
  - lib/bcms_tools/form_helpers.rb
67
+ - lib/bcms_tools/migration_helpers.rb
67
68
  - lib/bcms_tools/view_helpers.rb
68
69
  - lib/bcms_tools_dev.rb
69
70
  - rails/init.rb