Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve db setup #503

Closed
artur-intech opened this issue May 4, 2017 · 7 comments
Closed

Improve db setup #503

artur-intech opened this issue May 4, 2017 · 7 comments
Assignees

Comments

@artur-intech
Copy link
Contributor

artur-intech commented May 4, 2017

Remove db/schema-read-only.rb and keep using db/structure.sql only. Merging the former requires additional effort with no benefit.

Simplify lib/tasks/db.rake and use standard rake tasks as much as possible.

Remove rake tasks:

  • db:all:setup
  • db:all:create
  • db:all:drop
  • db:all:schema:load
  • db:all:schema:dump

Introduce new rake tasks (custom):

  • db:setup:all
  • db:schema:load:all
  • db:schema:dump:all
@artur-intech
Copy link
Contributor Author

@ratM1n @teadur FYI

artur-intech pushed a commit that referenced this issue May 4, 2017
@teadur
Copy link
Contributor

teadur commented May 4, 2017

Which standard rake tasks provide the functionality of the removed rake tasks ?
If we change/remove tasks we need to update docs.

@artur-intech
Copy link
Contributor Author

artur-intech commented May 4, 2017

@teadur

  1. Everything found by running rake -T | grep db (they have very similar names as the removed ones)
  2. Docs are updated. Would be good if you double-check
  3. Also, would be great to ensure removed ones are not used by any env I am not aware of

@ratM1n
Copy link

ratM1n commented May 5, 2017

output from all new tasks:

`
HEAD is now at 27ee3b2... Improve db setup
import@staging:~/registry$ RAILS_ENV=staging rake --trace db:setup:all
** Invoke db:setup:all (first_time)
** Invoke environment (first_time)
** Execute environment
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:

  • development - set it to false
  • test - set it to false (unless you use a tool that preloads your test environment)
  • production - set it to true

** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:setup:all
** Invoke db:create:all (first_time)
** Invoke db:load_config
** Execute db:create:all
registry_test already exists
registry_whois_test already exists
registry_api_log_test already exists
** Invoke db:structure:load (first_time)
** Invoke db:load_config
** Execute db:structure:load
** Invoke db:schema:load:all (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:load:all

------------------------ api_log_staging schema loading -----------------------------
-- enable_extension("plpgsql")
-> 0.0347s
-- create_table("epp_logs", {:force=>:cascade})
-> 0.0271s
-- add_index("epp_logs", ["uuid"], {:name=>"epp_logs_uuid", :using=>:btree})
-> 0.0083s
-- create_table("repp_logs", {:force=>:cascade})
-> 0.0120s
-- add_index("repp_logs", ["uuid"], {:name=>"repp_logs_uuid", :using=>:btree})
-> 0.0084s
-- initialize_schema_migrations_table()
-> 0.0209s

------------------------ whois_staging schema loading -----------------------------
-- create_table("whois_records", {:force=>:cascade})
-> 0.0483s
-- add_index("whois_records", ["name"], {:name=>"index_domains_on_name", :using=>:btree})
-> 0.0073s
-- initialize_schema_migrations_table()
-> 0.0119s

---------------------------- Import seed ----------------------------------------
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment
** Execute db:abort_if_pending_migrations

All done!

import@staging:~/registry$ RAILS_ENV=staging rake --trace db:schema:dump:all
** Invoke db:schema:dump:all (first_time)
** Invoke environment (first_time)
** Execute environment
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:

  • development - set it to false
  • test - set it to false (unless you use a tool that preloads your test environment)
  • production - set it to true

** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:dump:all

---------------------------- staging schema dump--------------

---------------------------- api_log_staging ----------------------------------------
DEPRECATION WARNING: Passing a string to ActiveRecord::Base.establish_connection for a configuration lookup is deprecated, please pass a symbol (:api_log_staging) instead. (called from block (6 levels) in <top (required)> at /home/import/registry/lib/tasks/db.rake:58)

---------------------------- whois_staging ----------------------------------------
DEPRECATION WARNING: Passing a string to ActiveRecord::Base.establish_connection for a configuration lookup is deprecated, please pass a symbol (:whois_staging) instead. (called from block (6 levels) in <top (required)> at /home/import/registry/lib/tasks/db.rake:58)
import@staging:~/registry$ RAILS_ENV=staging rake --trace db:schema:load:all
** Invoke db:schema:load:all (first_time)
** Invoke environment (first_time)
** Execute environment
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:

  • development - set it to false
  • test - set it to false (unless you use a tool that preloads your test environment)
  • production - set it to true

** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:load:all

------------------------ api_log_staging schema loading -----------------------------
-- enable_extension("plpgsql")
-> 0.0396s
-- create_table("epp_logs", {:force=>:cascade})
-> 0.0383s
-- add_index("epp_logs", ["uuid"], {:name=>"epp_logs_uuid", :using=>:btree})
-> 0.0084s
-- create_table("repp_logs", {:force=>:cascade})
-> 0.0283s
-- add_index("repp_logs", ["uuid"], {:name=>"repp_logs_uuid", :using=>:btree})
-> 0.0079s
-- initialize_schema_migrations_table()
-> 0.0070s

------------------------ whois_staging schema loading -----------------------------
-- enable_extension("plpgsql")
-> 0.0387s
-- create_table("whois_records", {:force=>:cascade})
-> 0.0363s
-- add_index("whois_records", ["name"], {:name=>"index_domains_on_name", :using=>:btree})
-> 0.0084s
-- initialize_schema_migrations_table()
-> 0.0012s
`

@vohmar
Copy link
Contributor

vohmar commented May 19, 2017

in master, not yet deployed to production

@ratM1n
Copy link

ratM1n commented Jun 8, 2017

OK, all nessecery tables and schemas are created with db:setup:all

@vohmar
Copy link
Contributor

vohmar commented Jun 16, 2017

in production

@vohmar vohmar closed this as completed Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants