lportal 1.0.19 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +3 -0
- data/active_record/fixtures.rb +21 -0
- data/config/database-mysql.yml +16 -0
- data/config/database-postgresql.yml +16 -0
- data/config/database.yml +16 -0
- data/lportal.rb +9 -13
- data/tasks/database.rake +83 -0
- data/tasks/env.rake +15 -0
- data/tasks/fixtures.rake +35 -0
- data/tasks/migrate.rake +28 -0
- data/version.rb +1 -1
- metadata +12 -4
data/ChangeLog
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
# Alter fixture typecase.
|
5
|
+
module TestFixtures
|
6
|
+
module ClassMethods
|
7
|
+
|
8
|
+
alias :original_fixtures :fixtures
|
9
|
+
|
10
|
+
# On PostgreSQL, use downcase table names
|
11
|
+
def fixtures(*table_names)
|
12
|
+
case ActiveRecord::Base.connection.adapter_name
|
13
|
+
when 'PostgreSQL'
|
14
|
+
table_names = table_names.flatten.collect{ |n| n.to_s.downcase }
|
15
|
+
end
|
16
|
+
original_fixtures(table_names)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
production:
|
2
|
+
adapter: mysql
|
3
|
+
database: lportal
|
4
|
+
username: lportal_user
|
5
|
+
password: lportal
|
6
|
+
host: 127.0.0.1
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
test:
|
10
|
+
adapter: mysql
|
11
|
+
database: lportal_test
|
12
|
+
username: rails_tester
|
13
|
+
password: rails
|
14
|
+
host: 127.0.0.1
|
15
|
+
timeout: 5000
|
16
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
production:
|
2
|
+
adapter: postgresql
|
3
|
+
database: lportal
|
4
|
+
username: lportal_user
|
5
|
+
password: lportal
|
6
|
+
host: 127.0.0.1
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
test:
|
10
|
+
adapter: postgresql
|
11
|
+
database: lportal_test
|
12
|
+
username: rails_tester
|
13
|
+
password: rails
|
14
|
+
host: 127.0.0.1
|
15
|
+
timeout: 5000
|
16
|
+
|
data/config/database.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
production:
|
2
|
+
adapter: postgresql
|
3
|
+
database: lportal
|
4
|
+
username: lportal_user
|
5
|
+
password: lportal
|
6
|
+
host: 127.0.0.1
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
test:
|
10
|
+
adapter: postgresql
|
11
|
+
database: lportal_test
|
12
|
+
username: rails_tester
|
13
|
+
password: rails
|
14
|
+
host: 127.0.0.1
|
15
|
+
timeout: 5000
|
16
|
+
|
data/lportal.rb
CHANGED
@@ -32,19 +32,15 @@ Find.find(File.join(this_dir,'lib')) do |file|
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
STDOUT.puts 'Lportal v.%s using ActiveRecord v.%s' % [Lportal::VERSION, ActiveRecord::VERSION::STRING]
|
36
|
+
|
35
37
|
# define this database's schema version
|
36
38
|
require File.join(this_dir,'schema')
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
msg = 'Using Liferay schema build %i, version %s' % [
|
45
|
-
Lportal::Schema.buildnumber, Lportal::Schema.version]
|
46
|
-
|
47
|
-
defined?(RAILS_DEFAULT_LOGGER) ?
|
48
|
-
RAILS_DEFAULT_LOGGER.info(msg) : STDOUT.puts(msg)
|
39
|
+
begin
|
40
|
+
Lportal::Schema.buildnumber = Release.current.buildnumber
|
41
|
+
STDOUT.puts 'Using Liferay schema build %i, version %s' % [
|
42
|
+
Lportal::Schema.buildnumber, Lportal::Schema.version]
|
43
|
+
rescue
|
44
|
+
STDERR.puts 'Error while detecting Liferay schema version'
|
45
|
+
end
|
49
46
|
|
50
|
-
puts 'ActiveRecord v.%s' % ActiveRecord::VERSION::STRING
|
data/tasks/database.rake
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# helper for dbconfig
|
2
|
+
def loadDbconf
|
3
|
+
YAML.load_file('config/database.yml')
|
4
|
+
end
|
5
|
+
|
6
|
+
namespace :db do
|
7
|
+
namespace :mysql do
|
8
|
+
|
9
|
+
desc 'creates DBs and DBUsers'
|
10
|
+
task :create, [:user, :pass] do |t, args|
|
11
|
+
if args.user.nil?
|
12
|
+
puts "aborted, requires mysql admin user+pass!"
|
13
|
+
else
|
14
|
+
require "mysql"
|
15
|
+
STDOUT.puts 'Connecting to MySQL with NO password' if args.pass.nil?
|
16
|
+
|
17
|
+
# for each environment defined in database.yml
|
18
|
+
loadDbconf.each do |e, confEnv|
|
19
|
+
mysql = Mysql::new(confEnv['host'], args.user, args.pass, "mysql")
|
20
|
+
mysql.query "CREATE DATABASE #{confEnv['database']} CHARACTER SET utf8;"
|
21
|
+
mysql.query "GRANT ALL PRIVILEGES ON #{confEnv['database']}.* TO #{confEnv['username']}@'%' IDENTIFIED BY '#{confEnv['password']}';"
|
22
|
+
mysql.query "FLUSH PRIVILEGES;"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'drops DBs and DBUsers'
|
28
|
+
task :drop, [:user, :pass] do |t, args|
|
29
|
+
if args.user.nil? || args.pass.nil?
|
30
|
+
puts "aborted, requires mysql admin user+pass!"
|
31
|
+
else
|
32
|
+
require "mysql"
|
33
|
+
# for each environment defined in database.yml
|
34
|
+
loadDbconf.each do |e, confEnv|
|
35
|
+
mysql = Mysql::new(confEnv['host'], args.user, args.pass, "mysql")
|
36
|
+
mysql.query "DROP DATABASE #{confEnv['database']};"
|
37
|
+
mysql.query "DROP USER #{confEnv['username']}@'%';"
|
38
|
+
mysql.query "FLUSH PRIVILEGES;"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
task :import => :prepareimports do |t, args|
|
44
|
+
|
45
|
+
require "mysql"
|
46
|
+
# for each environment defined in database.yml
|
47
|
+
loadDbconf.each do |e, confEnv|
|
48
|
+
mysql = Mysql::connect(confEnv['host'], confEnv['username'], confEnv['password'], confEnv['database'])
|
49
|
+
mysql.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON)
|
50
|
+
sqlBatch = File.open('tmp/prepared_imports.sql').read
|
51
|
+
mysql.query(sqlBatch)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# prepare the vendor-sql-statements
|
58
|
+
desc 'create tmp/prepared_imports.sql from vendor/..sql'
|
59
|
+
task :prepareimports do
|
60
|
+
|
61
|
+
# fixme other adapters..
|
62
|
+
ENV['LPORTAL_ENV'] = 'test'
|
63
|
+
require 'db_connection'
|
64
|
+
adapterName = ActiveRecord::Base.connection.adapter_name.downcase
|
65
|
+
|
66
|
+
sql = ''
|
67
|
+
file = File.open('vendor/liferay-portal-sql-5.2.3/create-minimal/create-minimal-'+adapterName+'.sql')
|
68
|
+
begin
|
69
|
+
while (line = file.readline)
|
70
|
+
if (line =~ /(drop|create) database|use /)
|
71
|
+
sql += '-- ' + line
|
72
|
+
else
|
73
|
+
sql += line
|
74
|
+
end
|
75
|
+
end
|
76
|
+
rescue EOFError
|
77
|
+
file.close
|
78
|
+
end
|
79
|
+
Dir.mkdir('tmp') unless File.exists?('tmp')
|
80
|
+
File.open('tmp/prepared_imports.sql', 'w') {|f| f.write(sql) }
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/tasks/env.rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
namespace :db do
|
2
|
+
task :environment do
|
3
|
+
ENV['LPORTAL_ENV'] = 'production'
|
4
|
+
require 'db_connection'
|
5
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
6
|
+
ActiveRecord::Base.logger.level = Logger::FATAL
|
7
|
+
require 'init'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :test do
|
12
|
+
task :environment do
|
13
|
+
# in test_helper
|
14
|
+
end
|
15
|
+
end
|
data/tasks/fixtures.rake
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
desc 'Creates YAML fixtures from live data.'
|
2
|
+
task :fixtures do
|
3
|
+
ENV['LPORTAL_ENV'] = 'production'
|
4
|
+
|
5
|
+
# Load ActiveRecord
|
6
|
+
require 'rails_gem_chooser'
|
7
|
+
RailsGemChooser.__load
|
8
|
+
|
9
|
+
require 'db_connection'
|
10
|
+
require 'init'
|
11
|
+
require 'test/test_case'
|
12
|
+
|
13
|
+
unless File.exists?(ActiveSupport::TestCase.fixture_path)
|
14
|
+
FileUtils.mkdir_p(ActiveSupport::TestCase.fixture_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
sql = "SELECT * from %s"
|
18
|
+
|
19
|
+
ActiveRecord::Base.connection.tables.each do |table|
|
20
|
+
i = "000"
|
21
|
+
File.open(
|
22
|
+
File.join(
|
23
|
+
ActiveSupport::TestCase.fixture_path,
|
24
|
+
table+'.yml'),
|
25
|
+
'w'
|
26
|
+
) do |file|
|
27
|
+
puts "* %s" % file.inspect
|
28
|
+
data = ActiveRecord::Base.connection.select_all(sql % table)
|
29
|
+
file.write data.inject({}) { |hash, record|
|
30
|
+
hash["#{table}_#{i.succ!}"] = record
|
31
|
+
hash
|
32
|
+
}.to_yaml
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/tasks/migrate.rake
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
namespace :db do
|
2
|
+
|
3
|
+
desc "Migrates lportal database tables"
|
4
|
+
task :migrate => :environment do
|
5
|
+
|
6
|
+
# first run lportal sequence migrations (TODO)
|
7
|
+
info('Running lportal migrations')
|
8
|
+
ActiveRecord::Migrator.migrate(LPORTAL_MIGRATIONS)
|
9
|
+
|
10
|
+
#Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
11
|
+
info 'You need to manually run rake db:schema:dump'
|
12
|
+
|
13
|
+
#Rake::Task['db:update'].invoke
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Wipes out lportal database tables"
|
17
|
+
task :rollback => :environment do
|
18
|
+
|
19
|
+
version = ENV['VERSION'].to_i || 0
|
20
|
+
|
21
|
+
info('Reverting lportal migrations')
|
22
|
+
ActiveRecord::Migrator.migrate(LPORTAL_MIGRATIONS, version)
|
23
|
+
|
24
|
+
#Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
25
|
+
info 'You need to manually run rake db:schema:dump'
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lportal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 20
|
10
|
+
version: 1.0.20
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mikael Lammentausta
|
@@ -15,7 +15,7 @@ autorequire: init
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-25 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -130,6 +130,14 @@ files:
|
|
130
130
|
- Rakefile
|
131
131
|
- migrations/20090101000001_add_sequences.rb
|
132
132
|
- migrations/20090309000001_portlet_properties.rb
|
133
|
+
- tasks/database.rake
|
134
|
+
- tasks/env.rake
|
135
|
+
- tasks/fixtures.rake
|
136
|
+
- tasks/migrate.rake
|
137
|
+
- active_record/fixtures.rb
|
138
|
+
- config/database-mysql.yml
|
139
|
+
- config/database-postgresql.yml
|
140
|
+
- config/database.yml
|
133
141
|
- test/unit/account_test.rb
|
134
142
|
- test/unit/address_test.rb
|
135
143
|
- test/unit/announcement/delivery_test.rb
|