Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
4f5588b8
Commit
4f5588b8
authored
Nov 15, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic docs for troubleshooting database problems
parent
0f5faea4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
+50
-0
doc/development/README.md
doc/development/README.md
+1
-0
doc/development/database_debugging.md
doc/development/database_debugging.md
+49
-0
No files found.
doc/development/README.md
View file @
4f5588b8
...
...
@@ -71,6 +71,7 @@ comments: false
-
[
Iterating tables in batches
](
iterating_tables_in_batches.md
)
-
[
Ordering table columns
](
ordering_table_columns.md
)
-
[
Verifying database capabilities
](
verifying_database_capabilities.md
)
-
[
Database Debugging and Troubleshooting
](
database_debugging.md
)
## Testing guides
...
...
doc/development/database_debugging.md
0 → 100644
View file @
4f5588b8
# Database Debugging and Troubleshooting
This section is to help give some copy-pasta you can use as a reference when you
run into some head-banging database problems.
An easy first step is to search for your error in Slack or google "GitLab
<my
error
>
".
---
Available
`RAILS_ENV`
-
`production`
(not sure if in GDK)
-
`development`
(this is your main GDK db)
-
`test`
(used for tests like rspec and spinach)
## Nuke everything and start over
If you just want to delete everything and start over,
-
`bundle exec rake db:drop RAILS_ENV=development`
-
`bundle exec rake db:setup RAILS_ENV=development`
## Migration wrangling
-
`bundle exec rake db:migrate RAILS_ENV=development`
: Execute any pending migrations that you may have picked up from a MR
-
`bundle exec rake db:migrate:status RAILS_ENV=development`
: Check if all migrations are
`up`
or
`down`
-
`bundle exec rake db:migrate:down VERSION=20170926203418 RAILS_ENV=development`
: Tear down a migration
-
`bundle exec rake db:migrate:up VERSION=20170926203418 RAILS_ENV=development`
: Setup a migration
-
`bundle exec rake db:migrate:redo VERSION=20170926203418 RAILS_ENV=development`
: Re-run a specific migration
## Manually access the database
Access the database via one of these commands (they all get you to the same place)
```
gdk psql -d gitlabhq_development
bundle exec rails dbconsole RAILS_ENV=development
bundle exec rails db RAILS_ENV=development
```
-
`\q`
: Quit/exit
-
`\dt`
: List all tables
-
`\d+ issues`
: List columns for
`issues`
table
-
`CREATE TABLE board_labels();`
: Create a table called
`board_labels`
-
`SELECT * FROM schema_migrations WHERE version = '20170926203418';`
: Check if a migration was run
-
`DELETE FROM schema_migrations WHERE version = '20170926203418';`
: Manually remove a migration
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment