prick 0.29.2 → 0.31.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO +2 -0
- data/exe/prick +294 -519
- data/idea.txt +38 -0
- data/lib/prick/builder/batch.rb +1 -4
- data/lib/prick/builder/builder.rb +15 -9
- data/lib/prick/builder/node.rb +3 -2
- data/lib/prick/builder/node_pool.rb +3 -1
- data/lib/prick/builder/parser.rb +2 -1
- data/lib/prick/constants.rb +12 -12
- data/lib/prick/diff.rb +2 -2
- data/lib/prick/environment.rb +30 -12
- data/lib/prick/local/command.rb +8 -2
- data/lib/prick/local/fmt.rb +56 -0
- data/lib/prick/prick_version.rb +1 -1
- data/lib/prick/share/init/{.gitignore → dot.gitignore} +1 -1
- data/lib/prick/share/init/prick.environment.yml +16 -0
- data/lib/prick/share/init/prick.yml +3 -3
- data/lib/prick/share/init/schema/prick/build.yml +11 -2
- data/lib/prick/share/init/schema/prick/tables.sql +30 -9
- data/lib/prick/share/init/schema/prick/views.sql +6 -0
- data/lib/prick/state.rb +304 -95
- data/lib/prick/subcommand/prick-build.rb +26 -20
- data/lib/prick/subcommand/prick-clean.rb +5 -5
- data/lib/prick/subcommand/prick-create.rb +42 -7
- data/lib/prick/subcommand/prick-drop.rb +41 -14
- data/lib/prick/subcommand/prick-fox.rb +1 -1
- data/lib/prick/subcommand/prick-init.rb +25 -18
- data/lib/prick/subcommand/prick-list.rb +99 -0
- data/lib/prick/subcommand/prick-make.rb +8 -8
- data/lib/prick/subcommand/prick-migrate.rb +8 -7
- data/lib/prick/subcommand/prick-release.rb +4 -2
- data/lib/prick/subcommand/prick-set.rb +52 -0
- data/lib/prick/subcommand/prick-setup.rb +3 -13
- data/lib/prick/subcommand/prick-teardown.rb +13 -9
- data/lib/prick/subcommand/subcommand.rb +12 -0
- data/lib/prick/version.rb +1 -1
- data/lib/prick.rb +54 -15
- metadata +14 -9
- data/lib/prick/share/init/schema/prick/data.sql +0 -6
- data/prick.environments.yml +0 -14
@@ -3,28 +3,55 @@
|
|
3
3
|
require_relative '../builder/builder.rb'
|
4
4
|
|
5
5
|
module Prick::SubCommand
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
# Drop database owner
|
7
|
+
def self.drop_owner(username)
|
8
|
+
# No database at this point so no session is running and no cascade. A nop
|
9
|
+
# if the user is the current user or owns objects in other databases
|
10
|
+
if username != ENV['USER']
|
11
|
+
super_conn.role.drop(username, fail: false, silent: true)
|
12
|
+
end
|
10
13
|
end
|
11
14
|
|
12
|
-
# Drop all users associated with the given database except the owner
|
15
|
+
# Drop all users associated with the given database except the owner. We
|
16
|
+
# assume that users can only be connected to the project database and that
|
17
|
+
# they don't own objects in other databases
|
13
18
|
def self.drop_users(database)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
19
|
+
constrain database, String
|
20
|
+
conn = super_conn
|
21
|
+
if conn.rdbms.exist? database
|
22
|
+
users = conn.role.list(database: database).reject { _1 == conn.rdbms.owner(database) }
|
23
|
+
conn.session.terminate(database, users)
|
24
|
+
if conn.rdbms.exist?(database)
|
25
|
+
# Connect to database to make cascade work. Run in a block to close connection afterwards
|
26
|
+
PgConn.new(database) { |conn| conn.role.drop(users, cascade: true) }
|
27
|
+
else
|
28
|
+
conn.rdbms.role.drop(users)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
# We don't terminate sessions because we assume one-database-users
|
32
|
+
# FIXME: users is undefined
|
33
|
+
raise NotImpementedError
|
34
|
+
conn.role.drop(users, cascade: true) # Fails if the users owns objects in other databases
|
35
|
+
end
|
18
36
|
end
|
19
37
|
|
38
|
+
# Drop a database
|
20
39
|
def self.drop_database(database)
|
21
|
-
|
40
|
+
State.connection.session.terminate(database, nil)
|
41
|
+
State.connection { |conn| conn.rdbms.drop database }
|
22
42
|
end
|
23
43
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
44
|
+
# Empty the database
|
45
|
+
def self.drop_schema(database, schemas = [])
|
46
|
+
constrain database, String
|
47
|
+
constrain schemas, [String]
|
48
|
+
if schemas.empty?
|
49
|
+
State.connection { |conn| conn.rdbms.empty!(database, exclude: "prick") }
|
50
|
+
else
|
51
|
+
Prick.state.connection { |conn|
|
52
|
+
schemas.each { |schema| conn.schema.drop(schema, cascade: true) }
|
53
|
+
}
|
54
|
+
end
|
28
55
|
end
|
29
56
|
end
|
30
57
|
|
@@ -1,46 +1,53 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
module Prick::SubCommand
|
4
|
-
def self.init(dir, name, title,
|
4
|
+
def self.init(project_file, dir, name, title) # dir, name, and title can be nil
|
5
|
+
cwd = Dir.getwd
|
5
6
|
if dir
|
6
|
-
!File.exist?(dir) or
|
7
|
+
!File.exist?(dir) or Prick.error "Directory #{dir} exists"
|
7
8
|
FileUtils.mkdir_p(dir)
|
8
9
|
Dir.chdir(dir)
|
9
10
|
else
|
10
11
|
dir = "."
|
11
12
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
username ||= name
|
13
|
+
dirname = File.basename(Dir.getwd)
|
14
|
+
name ||= dirname
|
15
|
+
title ||= name.gsub(/[_-]/, " ").capitalize
|
16
16
|
|
17
|
+
# Note that the initial project file is invalid and is removed again after
|
18
|
+
# the initial commit
|
17
19
|
Command.command %(
|
18
20
|
git init .
|
19
|
-
|
21
|
+
dir=#{SHARE_PATH}/init
|
22
|
+
for path in $dir/*; do
|
23
|
+
source_file=$(basename $path)
|
24
|
+
dest_file=$(sed 's/^dot\././' <<<$source_file)
|
25
|
+
cp -a $dir/$source_file $dest_file
|
26
|
+
done
|
20
27
|
git add .
|
21
28
|
git commit -am "Initial import"
|
29
|
+
rm -f #{project_file}
|
22
30
|
), fail: false
|
31
|
+
Command.status == 0 or Prick.failure "Failed creating initial import"
|
23
32
|
|
24
|
-
|
25
|
-
|
26
|
-
state = State.new
|
33
|
+
# Write (valid) configuration file
|
34
|
+
state = State.new(project_file, nil, nil)
|
27
35
|
state.name = name
|
28
36
|
state.title = title
|
29
37
|
state.prick_version = PrickVersion.new VERSION
|
30
38
|
state.version = PrickVersion.new("0.0.0")
|
31
|
-
state.
|
32
|
-
state.database = database
|
33
|
-
state.username = username
|
34
|
-
state.save
|
39
|
+
state.save_project
|
35
40
|
|
41
|
+
# Commit configuration file and create initial release
|
36
42
|
Command.command %(
|
37
43
|
set -e
|
44
|
+
git add #{project_file}
|
38
45
|
git commit -am "Release 0.0.0"
|
39
|
-
git tag v0.0.0
|
46
|
+
git tag --message "Initial Release" v0.0.0
|
40
47
|
), fail: false
|
48
|
+
Command.status == 0 or Prick.failure "Failed creating initial release"
|
41
49
|
|
42
|
-
|
43
|
-
|
44
|
-
[dir, state]
|
50
|
+
Dir.chdir(cwd)
|
51
|
+
[dir, name]
|
45
52
|
end
|
46
53
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Prick::SubCommand
|
2
|
+
def self.list_environments(format: :long)
|
3
|
+
environments = Environment.environments.select { |env| env.comment }
|
4
|
+
if format == :short
|
5
|
+
puts environments.map(&:name)
|
6
|
+
else
|
7
|
+
headers = %w(Environment Description)
|
8
|
+
rows = environments.map { |env| [env.name, env.comment] }
|
9
|
+
Fmt.puts_table(headers, rows)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.list_variables(format: :long, all: false)
|
14
|
+
if format == :short
|
15
|
+
puts Prick.state.bash_environment(all: all).keys
|
16
|
+
else
|
17
|
+
headers = %w(variable value)
|
18
|
+
vars = Prick.state.bash_environment(all: all).reject { |k,v| k == "PATH" }
|
19
|
+
rows = vars.map { |k,v| [k, Array(v).flatten.join(" ")] }
|
20
|
+
Fmt.puts_table(headers, rows)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.list_databases(format: :long)
|
25
|
+
constrain format, :long, :short
|
26
|
+
conn = State.connection
|
27
|
+
# databases = conn.values "select datname from pg_database where datistemplate = false order by datname;"
|
28
|
+
|
29
|
+
if format == :short
|
30
|
+
puts Prick.databases
|
31
|
+
else
|
32
|
+
fs_time = `find . -type f -not -path '*/\.*' -printf '%TF %TT\n' | sort -r | head -n 1`
|
33
|
+
git_branch = Git.branch.current
|
34
|
+
git_rev = Git.id[0...8]
|
35
|
+
|
36
|
+
rows = []
|
37
|
+
Prick.databases { |database, conn|
|
38
|
+
row = conn.record(%(
|
39
|
+
select
|
40
|
+
'#{database}' as "database", name, version, branch, rev, clean, environment,
|
41
|
+
to_char(
|
42
|
+
built_at at time zone 'UTC' at time zone current_setting('TimeZone'),
|
43
|
+
'YYYY-MM-DD HH24:MI') as "built_at",
|
44
|
+
success
|
45
|
+
from prick.versions
|
46
|
+
))
|
47
|
+
|
48
|
+
if row[:success]
|
49
|
+
clean = row[:clean]
|
50
|
+
same_revision = row[:branch] == git_branch && row[:rev] == git_rev
|
51
|
+
up2date = fs_time <= row[:built_at]
|
52
|
+
row[:state] =
|
53
|
+
case [clean, same_revision, up2date]
|
54
|
+
in [true, true, true]; "clean" # Clean repo
|
55
|
+
in [true, true, false]; "dirty" # Clean repo but doesn't include latest changes
|
56
|
+
in [true, false, _]; "detached" # Clean repo but different revision
|
57
|
+
|
58
|
+
in [false, true, true]; "ok" # Dirty repo
|
59
|
+
in [false, true, false]; "dirty" # Dirty repo, but doesn't include latest changes
|
60
|
+
in [false, false, _]; "stale" # Dirty repo, no way back
|
61
|
+
end
|
62
|
+
else
|
63
|
+
row[:state] = "-"
|
64
|
+
end
|
65
|
+
|
66
|
+
last_column = (Prick.state.database == database ? "*" : "")
|
67
|
+
rows << row.values + [last_column]
|
68
|
+
}
|
69
|
+
|
70
|
+
headers = %w(database project version branch rev clean environment built success state) + [" "]
|
71
|
+
Fmt.puts_table(headers, rows)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.list_users
|
76
|
+
puts State.connection.role.list(database: Prick.state.database)
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.list_owners(format: :long)
|
80
|
+
owners = {}
|
81
|
+
Prick.databases.each { |database|
|
82
|
+
# owner = super_conn.rdbms.exist?(d) ? super_conn.rdbms.owner(d) : d
|
83
|
+
owner = super_conn.rdbms.owner(database)
|
84
|
+
(owners[owner] ||= []) << database
|
85
|
+
}
|
86
|
+
if format == :short
|
87
|
+
puts owners.keys
|
88
|
+
else
|
89
|
+
headers = %w(username databases) + [" "]
|
90
|
+
rows = owners.map { |owner, databases|
|
91
|
+
current_user_mark = (Prick.state.username == owner ? '*' : "")
|
92
|
+
[owner, databases.join(","), current_user_mark]
|
93
|
+
}
|
94
|
+
Fmt.puts_table(headers, rows)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
@@ -7,22 +7,22 @@ module Prick::SubCommand
|
|
7
7
|
Timer.on! if timer
|
8
8
|
time "Prick::Command#make" do
|
9
9
|
begin
|
10
|
-
super_conn =
|
10
|
+
super_conn = State.connection
|
11
11
|
conn = nil
|
12
12
|
builder = nil
|
13
|
-
|
13
|
+
last_built_at = EPOCH
|
14
14
|
clean = false
|
15
15
|
create_schemas = []
|
16
16
|
|
17
17
|
time "Load build object" do
|
18
18
|
if super_conn.rdbms.exist? database
|
19
|
-
conn =
|
20
|
-
if conn.schema.
|
21
|
-
|
19
|
+
conn = Prick.state.connection
|
20
|
+
if conn.schema.exist_relation?("prick", "versions") && !conn.empty?("prick.versions")
|
21
|
+
last_built_at = conn.value("select built_at from prick.versions")
|
22
22
|
end
|
23
23
|
else
|
24
24
|
super_conn.rdbms.create database, owner: username
|
25
|
-
conn =
|
25
|
+
conn = Prick.state.connection
|
26
26
|
clean = true
|
27
27
|
end
|
28
28
|
|
@@ -43,7 +43,7 @@ module Prick::SubCommand
|
|
43
43
|
after_schemas.each { |delete_schema| builder.pool.delete_schema(delete_schema) }
|
44
44
|
end
|
45
45
|
|
46
|
-
touched_nodes = builder.nodes.select { |node| File.mtime(node.path) >
|
46
|
+
touched_nodes = builder.nodes.select { |node| File.mtime(node.path) > last_built_at }
|
47
47
|
touched_phases = touched_nodes.map(&:phase).uniq.compact
|
48
48
|
touched_kinds = touched_nodes.map(&:kind).uniq.compact
|
49
49
|
touched_schema = touched_nodes.first&.schema
|
@@ -74,7 +74,7 @@ module Prick::SubCommand
|
|
74
74
|
when :batches; builder.dump
|
75
75
|
when nil;
|
76
76
|
else
|
77
|
-
|
77
|
+
Prick.error "Illegal dump type: #{dump.inspect}"
|
78
78
|
end
|
79
79
|
exit if dump
|
80
80
|
|
@@ -3,12 +3,13 @@ module Prick
|
|
3
3
|
module SubCommand
|
4
4
|
# def self.migrate(database, username, file) TODO
|
5
5
|
def self.migrate(database, username, file: nil)
|
6
|
-
|
6
|
+
conn = Prick.state.connection
|
7
|
+
# PgConn.new(database, username) { |conn|
|
7
8
|
conn.schema.exist_relation? "prick", "versions" or
|
8
|
-
|
9
|
+
Prick.failure "Can't read version from database"
|
9
10
|
|
10
11
|
from_version = PrickVersion.new(conn.value "select version from prick.versions") or
|
11
|
-
|
12
|
+
Prick.failure "Illegal version in table prick.versions"
|
12
13
|
|
13
14
|
if file
|
14
15
|
conn.transaction {
|
@@ -16,12 +17,12 @@ module Prick
|
|
16
17
|
}
|
17
18
|
else
|
18
19
|
to_version = Prick.state.version
|
19
|
-
from_version != to_version or
|
20
|
-
from_version < to_version or
|
20
|
+
from_version != to_version or Prick.failure "Already up to date"
|
21
|
+
from_version < to_version or Prick.failure "Can't migrate backwards"
|
21
22
|
|
22
23
|
migration_dir = "#{MIGRATION_DIR}/#{from_version}"
|
23
24
|
File.directory? migration_dir or
|
24
|
-
|
25
|
+
Prick.failure "Can't migrate from #{from_version} to #{to_version}"
|
25
26
|
|
26
27
|
puts "Migrating from #{from_version} to #{to_version}"
|
27
28
|
|
@@ -31,7 +32,7 @@ module Prick
|
|
31
32
|
conn.exec File.read(SCHEMA_VERSION_PATH)
|
32
33
|
}
|
33
34
|
end
|
34
|
-
|
35
|
+
# }
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
@@ -8,15 +8,17 @@ module Prick
|
|
8
8
|
Git.synchronized? or raise "Won't release: Repository is not synchronized with origin"
|
9
9
|
|
10
10
|
version = Prick.state.version.increment!(kind).to_s
|
11
|
-
Prick.state.
|
11
|
+
Prick.state.save_project
|
12
12
|
|
13
|
-
Git.add(Prick.state.
|
13
|
+
Git.add(Prick.state.project_file)
|
14
14
|
Git.add(Prick.state.schema_file)
|
15
15
|
Git.commit "Release #{version}"
|
16
16
|
Git.tag.create "v#{version}"
|
17
17
|
Git.branch.create version
|
18
18
|
Git.push
|
19
19
|
|
20
|
+
# TODO TODO TODO
|
21
|
+
|
20
22
|
puts version
|
21
23
|
end
|
22
24
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'time' # For Time#parse
|
2
|
+
|
3
|
+
module Prick::SubCommand
|
4
|
+
def self.set(variable, value = nil, arg = nil)
|
5
|
+
case variable
|
6
|
+
when "database"; set_database(value, arg)
|
7
|
+
when "environment"; set_environment(value)
|
8
|
+
when "duration"; set_duration(value)
|
9
|
+
else
|
10
|
+
return false
|
11
|
+
end
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.set_environment(environment)
|
16
|
+
if environment
|
17
|
+
Prick.state.environment = environment
|
18
|
+
Prick.state.save_state
|
19
|
+
else
|
20
|
+
puts Prick.state.environment
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# If the environment is nil, it is initialized from the database on next build
|
25
|
+
def self.set_database(database, environment = nil)
|
26
|
+
if database
|
27
|
+
conn = State.connection
|
28
|
+
conn.rdbms.exist? database or Prick.error "Database '#{database}' does not exist"
|
29
|
+
username = conn.rdbms.owner database
|
30
|
+
|
31
|
+
Prick.state.database = database
|
32
|
+
Prick.state.username = username
|
33
|
+
|
34
|
+
if environment.nil?
|
35
|
+
Prick.state.connection # Implicitly initialize database enviroment if present
|
36
|
+
environment = Prick.state.database_environment # or Prick.error "Can't find environment"
|
37
|
+
end
|
38
|
+
Prick.state.environment = environment
|
39
|
+
Prick.state.save_state
|
40
|
+
else
|
41
|
+
puts Prick.state.database
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.set_duration(make_start)
|
46
|
+
conn = Prick.state.connection
|
47
|
+
built_at = conn.value "select built_at from prick.versions"
|
48
|
+
duration = Time.now - Time.iso8601(make_start)
|
49
|
+
conn.exec "update prick.versions set make_duration = #{duration}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -3,18 +3,8 @@
|
|
3
3
|
require_relative '../builder/builder.rb'
|
4
4
|
|
5
5
|
module Prick::SubCommand
|
6
|
-
def self.setup(database, username)
|
7
|
-
|
8
|
-
|
9
|
-
# FIXME Should not be created as superuser but we can't do that before we
|
10
|
-
# have a super: option in build
|
11
|
-
conn.role.create username, superuser: true, can_login: true, create_role: true
|
12
|
-
end
|
13
|
-
if !conn.rdbms.exist? database
|
14
|
-
conn.rdbms.create database, owner: username
|
15
|
-
end
|
16
|
-
builder = Prick::Build::Builder.new(conn, "schema")
|
17
|
-
# TODO Run builder setup scrips
|
6
|
+
def self.setup(database, username, environment)
|
7
|
+
create_database(database, username, environment)
|
8
|
+
set_database(database, environment)
|
18
9
|
end
|
19
10
|
end
|
20
|
-
|
@@ -3,17 +3,21 @@
|
|
3
3
|
require_relative '../builder/builder.rb'
|
4
4
|
|
5
5
|
module Prick::SubCommand
|
6
|
-
def self.teardown(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
def self.teardown(*databases, remove_state_file: false)
|
7
|
+
databases = Array(databases).flatten
|
8
|
+
owners = databases.map { |d|
|
9
|
+
super_conn.rdbms.exist?(d) ? super_conn.rdbms.owner(d) : d
|
10
|
+
}.uniq
|
11
|
+
users = databases.map { |d| super_conn.role.list(database: d) }.flatten.uniq
|
12
|
+
|
13
|
+
databases.each { |d| drop_database(d) }
|
14
|
+
super_conn.role.drop(users)
|
15
|
+
super_conn.role.drop(owners, fail: false)
|
16
|
+
owners.each { |o| drop_owner(o) }
|
17
|
+
|
18
|
+
FileUtils.rm_f Prick.state.state_file if remove_state_file
|
14
19
|
|
15
20
|
# TODO Run builder teardown scrips
|
16
|
-
# builder = Prick::Build::Builder.new(conn, "schema")
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
data/lib/prick/version.rb
CHANGED
data/lib/prick.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require 'prick/version.rb'
|
2
2
|
|
3
3
|
require 'pg_conn'
|
4
4
|
|
@@ -8,7 +8,7 @@ require 'constrain'
|
|
8
8
|
|
9
9
|
module Prick
|
10
10
|
class Error < RuntimeError; end
|
11
|
-
class
|
11
|
+
class Failure < RuntimeError; end
|
12
12
|
end
|
13
13
|
|
14
14
|
require_relative 'prick/constants.rb'
|
@@ -18,6 +18,7 @@ require_relative 'prick/local/command.rb'
|
|
18
18
|
require_relative 'prick/local/git.rb'
|
19
19
|
require_relative 'prick/local/timer.rb'
|
20
20
|
require_relative 'prick/local/ansi.rb'
|
21
|
+
require_relative 'prick/local/fmt.rb'
|
21
22
|
|
22
23
|
require_relative 'prick/environment.rb'
|
23
24
|
require_relative 'prick/state.rb'
|
@@ -25,27 +26,65 @@ require_relative 'prick/prick_version.rb'
|
|
25
26
|
require_relative 'prick/diff.rb'
|
26
27
|
|
27
28
|
module Prick
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
29
|
+
def mesg(*msgs) = Prick.mesg(*msgs)
|
30
|
+
def verb(*msgs) = Prick.verb(*msgs)
|
31
|
+
def self.mesg(*msgs) puts msgs.join(" ") if !$quiet end
|
32
|
+
def self.verb(*msgs) puts msgs.join(" ") if $verbose && !$quiet end
|
33
33
|
end
|
34
34
|
|
35
|
-
require_relative 'prick/subcommand/
|
36
|
-
require_relative 'prick/subcommand/prick-
|
37
|
-
require_relative 'prick/subcommand/prick-teardown.rb'
|
35
|
+
require_relative 'prick/subcommand/subcommand.rb'
|
36
|
+
require_relative 'prick/subcommand/prick-build.rb'
|
38
37
|
require_relative 'prick/subcommand/prick-clean.rb'
|
39
38
|
require_relative 'prick/subcommand/prick-create.rb'
|
40
|
-
require_relative 'prick/subcommand/prick-build.rb'
|
41
|
-
require_relative 'prick/subcommand/prick-make.rb'
|
42
|
-
require_relative 'prick/subcommand/prick-fox.rb'
|
43
39
|
require_relative 'prick/subcommand/prick-drop.rb'
|
44
|
-
require_relative 'prick/subcommand/prick-
|
40
|
+
require_relative 'prick/subcommand/prick-set.rb'
|
41
|
+
require_relative 'prick/subcommand/prick-list.rb'
|
42
|
+
require_relative 'prick/subcommand/prick-fox.rb'
|
43
|
+
require_relative 'prick/subcommand/prick-init.rb'
|
44
|
+
require_relative 'prick/subcommand/prick-make.rb'
|
45
45
|
require_relative 'prick/subcommand/prick-migrate.rb'
|
46
|
+
require_relative 'prick/subcommand/prick-release.rb'
|
47
|
+
require_relative 'prick/subcommand/prick-setup.rb'
|
48
|
+
require_relative 'prick/subcommand/prick-teardown.rb'
|
46
49
|
|
47
50
|
module Prick
|
48
51
|
@state = nil
|
49
|
-
def self.state()
|
52
|
+
def self.state?() !@state.nil? end
|
53
|
+
def self.state() @state or raise ArgumentError end
|
50
54
|
def self.state=(state) @state = state end
|
55
|
+
|
56
|
+
def self.error(*args) raise Prick::Error.new *args end
|
57
|
+
def self.failure(*args) raise Prick::Failure.new *args end
|
58
|
+
|
59
|
+
def self.owner_conn = state.connection
|
60
|
+
def self.super_conn = State.connection
|
61
|
+
# def self.conn = owner_conn
|
62
|
+
|
63
|
+
# Return list of prick databases. If a block is given it is called with a
|
64
|
+
# connection to each of the databases
|
65
|
+
def self.databases(&block)
|
66
|
+
databases = super_conn.values %(
|
67
|
+
select datname from pg_database where datistemplate = false order by datname
|
68
|
+
)
|
69
|
+
databases.select! { |database|
|
70
|
+
PgConn.new(database) { |conn|
|
71
|
+
is_prick_database = conn.exist?(%(
|
72
|
+
select 1
|
73
|
+
from information_schema.tables
|
74
|
+
where table_schema = 'prick'
|
75
|
+
and table_name = 'builds'
|
76
|
+
limit 1
|
77
|
+
))
|
78
|
+
yield(database, conn) if is_prick_database && block_given?
|
79
|
+
is_prick_database
|
80
|
+
}
|
81
|
+
}
|
82
|
+
databases
|
83
|
+
end
|
84
|
+
|
85
|
+
module SubCommand
|
86
|
+
def self.owner_conn = Prick.owner_conn
|
87
|
+
def self.super_conn = Prick.super_conn
|
88
|
+
# def self.conn = Prick.conn
|
89
|
+
end
|
51
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semantic
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- bin/setup
|
183
183
|
- doc/build-yml.txt
|
184
184
|
- exe/prick
|
185
|
+
- idea.txt
|
185
186
|
- lib/prick.rb
|
186
187
|
- lib/prick/builder/batch.rb
|
187
188
|
- lib/prick/builder/builder.rb
|
@@ -194,19 +195,21 @@ files:
|
|
194
195
|
- lib/prick/ext/expand_variables.rb
|
195
196
|
- lib/prick/local/ansi.rb
|
196
197
|
- lib/prick/local/command.rb
|
198
|
+
- lib/prick/local/fmt.rb
|
197
199
|
- lib/prick/local/git.rb
|
198
200
|
- lib/prick/local/timer.rb
|
199
201
|
- lib/prick/prick_version.rb
|
200
|
-
- lib/prick/share/init/.gitignore
|
201
202
|
- lib/prick/share/init/.rspec
|
203
|
+
- lib/prick/share/init/dot.gitignore
|
202
204
|
- lib/prick/share/init/migration/.keep
|
205
|
+
- lib/prick/share/init/prick.environment.yml
|
203
206
|
- lib/prick/share/init/prick.yml
|
204
207
|
- lib/prick/share/init/schema/.keep
|
205
208
|
- lib/prick/share/init/schema/build.yml
|
206
209
|
- lib/prick/share/init/schema/prick/.keep
|
207
210
|
- lib/prick/share/init/schema/prick/build.yml
|
208
|
-
- lib/prick/share/init/schema/prick/data.sql
|
209
211
|
- lib/prick/share/init/schema/prick/tables.sql
|
212
|
+
- lib/prick/share/init/schema/prick/views.sql
|
210
213
|
- lib/prick/share/init/schema/public/.keep
|
211
214
|
- lib/prick/share/init/spec/prick_helper.rb
|
212
215
|
- lib/prick/share/init/spec/prick_spec.rb
|
@@ -222,18 +225,20 @@ files:
|
|
222
225
|
- lib/prick/subcommand/prick-drop.rb
|
223
226
|
- lib/prick/subcommand/prick-fox.rb
|
224
227
|
- lib/prick/subcommand/prick-init.rb
|
228
|
+
- lib/prick/subcommand/prick-list.rb
|
225
229
|
- lib/prick/subcommand/prick-make.rb
|
226
230
|
- lib/prick/subcommand/prick-migrate.rb
|
227
231
|
- lib/prick/subcommand/prick-release.rb
|
232
|
+
- lib/prick/subcommand/prick-set.rb
|
228
233
|
- lib/prick/subcommand/prick-setup.rb
|
229
234
|
- lib/prick/subcommand/prick-teardown.rb
|
235
|
+
- lib/prick/subcommand/subcommand.rb
|
230
236
|
- lib/prick/version.rb
|
231
|
-
- prick.environments.yml
|
232
237
|
- prick.gemspec
|
233
238
|
homepage: http://www.nowhere.com/
|
234
239
|
licenses: []
|
235
240
|
metadata: {}
|
236
|
-
post_install_message:
|
241
|
+
post_install_message:
|
237
242
|
rdoc_options: []
|
238
243
|
require_paths:
|
239
244
|
- lib
|
@@ -248,8 +253,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
253
|
- !ruby/object:Gem::Version
|
249
254
|
version: '0'
|
250
255
|
requirements: []
|
251
|
-
rubygems_version: 3.3.
|
252
|
-
signing_key:
|
256
|
+
rubygems_version: 3.3.7
|
257
|
+
signing_key:
|
253
258
|
specification_version: 4
|
254
259
|
summary: A release control and management system for postgresql
|
255
260
|
test_files: []
|