Skip to content
Snippets Groups Projects
Unverified Commit 92e79749 authored by Cam Saul's avatar Cam Saul
Browse files

Merge branch 'release-0.29.1' into sort-users-list

parents 262bf51b aaae69ed
No related branches found
No related tags found
No related merge requests found
Showing
with 223 additions and 57 deletions
......@@ -19,7 +19,8 @@
"extract": {
"output": "locales/metabase-frontend.pot"
},
"discover": ["t", "jt"]
"discover": ["t", "jt"],
"numberedExpressions": true
}]
]
}
......
......@@ -39,7 +39,8 @@
"react/no-did-update-set-state": 0,
"react/no-find-dom-node": 0,
"flowtype/define-flow-type": 1,
"flowtype/use-flow-type": 1
"flowtype/use-flow-type": 1,
"no-var": 1
},
"globals": {
"pending": false
......
......@@ -4,6 +4,10 @@
.*/node_modules/react-resizable/.*
.*/node_modules/documentation/.*
.*/node_modules/.*/\(lib\|test\).*\.json$
.*/node_modules/react-element-to-jsx-string/.*
.*/node_modules/react-element-to-jsx-string/.*
.*/node_modules/resize-observer-polyfill/.*
.*/node_modules/react-virtualized/.*
[include]
.*/frontend/.*
......
###### TODO
###### Before submitting the PR, please make sure you do the following
- [ ] If there are changes to the backend codebase, run the backend tests with `lein test && lein eastwood && lein bikeshed && lein docstring-checker && ./bin/reflection-linter`
- [ ] Run the frontend and integration tests with `yarn && yarn run prettier && yarn run lint && yarn run flow && ./bin/build version uberjar && yarn run test`)
- [ ] Sign the [Contributor License Agreement](https://docs.google.com/a/metabase.com/forms/d/1oV38o7b9ONFSwuzwmERRMi9SYrhYeOrkbmNaq9pOJ_E/viewform)
(unless it's a tiny documentation change).
......@@ -52,4 +52,5 @@ bin/release/aws-eb/metabase-aws-eb.zip
coverage-summary.json
.DS_Store
bin/node_modules/
*.log
\ No newline at end of file
*.log
*.trace.db
......@@ -15,13 +15,14 @@ container_commands:
#command: true
#ignoreErrors: false
01_server-name:
command: ".ebextensions/metabase_config/metabase-setup.sh server_name"
test: test $NGINX_SERVER_NAME
# do server_https first to avoid overwriting other config changes
01_server_https:
command: ".ebextensions/metabase_config/metabase-setup.sh server_https"
ignoreErrors: true
02_server_https:
command: ".ebextensions/metabase_config/metabase-setup.sh server_https"
02_server_name:
command: ".ebextensions/metabase_config/metabase-setup.sh server_name"
test: test $NGINX_SERVER_NAME
ignoreErrors: true
03_log_x_real_ip:
......
#!/usr/bin/env bash
set -eu
VERSION_PROPERTY_NAME="src_hash"
source-hash() {
# hash all the files that might change a backend-only uberjar build (for integration tests)
(
find src project.clj resources/sample-dataset.db.mv.db -type f -print0 | xargs -0 shasum ;
find resources -type f \( -iname \*.clj -o -iname \*.edn -o -iname \*.yaml -o -iname \*.properties \) -not -name "version.properties" -print0 | xargs -0 shasum ;
) | shasum | awk '{ print $1 }'
}
uberjar-hash() {
# java -jar target/uberjar/metabase.jar version | grep -oE 'source_hash [a-f0-9]+' | awk '{ print $2 }'
# pulling the version.properties directly from the jar is much faster
unzip -c target/uberjar/metabase.jar version.properties | grep "$VERSION_PROPERTY_NAME" | cut -f2 -d=
}
check-uberjar-hash() {
expected_hash=$(source-hash)
actual_hash=$(uberjar-hash)
if [ "$expected_hash" == "$actual_hash" ]; then
return 0
else
return 1
fi
}
build-uberjar-for-test() {
./bin/build version
echo "$VERSION_PROPERTY_NAME=$(source-hash)" >> resources/version.properties
./bin/build uberjar
}
if [ ! -f "target/uberjar/metabase.jar" ] || ! check-uberjar-hash; then
echo "Building uberjar for testing"
build-uberjar-for-test
else
echo "Uberjar already up to date for testing"
fi
......@@ -4,10 +4,13 @@
set -eu
node-0() {
is_enabled "drivers" && export ENGINES="h2,mongo,mysql,bigquery" || export ENGINES="h2"
is_enabled "drivers" && export ENGINES="h2,mongo,mysql,bigquery,sparksql" || export ENGINES="h2"
if is_engine_enabled "mongo"; then
run_step install-mongodb
fi
if is_engine_enabled "sparksql"; then
run_step install-sparksql
fi
MB_MYSQL_TEST_USER=ubuntu run_step lein-test
}
node-1() {
......@@ -58,12 +61,13 @@ node-5() {
run_step lein with-profile +ci eastwood
run_step yarn run test-karma
run_step yarn run test-unit
run_step yarn run test-unit --coverage
report-frontend-coverage
}
node-6() {
run_step ./bin/build version sample-dataset uberjar
run_step yarn run test-integrated
run_step ./bin/build-for-test
run_step check-uberjar-file-count
run_step yarn run test-integrated-no-build
}
report() {
......@@ -124,6 +128,29 @@ install-presto() {
sleep 10
}
install-sparksql() {
spark_version='2.1.1' # Java 7 support was removed in Spark 2.2 so don't upgrade until we upgrade CI
hadoop_version='2.7'
spark_archive="spark-${spark_version}-bin-hadoop${hadoop_version}.tgz"
wget --progress dot -e dotbytes=250K "https://archive.apache.org/dist/spark/spark-${spark_version}/${spark_archive}"
tar -xf $spark_archive
rm $spark_archive
spark_dir="$(pwd)/spark-${spark_version}-bin-hadoop${hadoop_version}"
java -Duser.timezone=Etc/UTC \
-Xmx512m \
-cp "${spark_dir}/conf:${spark_dir}/jars/*" \
org.apache.spark.deploy.SparkSubmit \
--master local[8] \
--conf spark.executor.extraJavaOptions=-Duser.timezone=Etc/UTC \
--conf spark.cores.max=1 \
--class org.apache.spark.sql.hive.thriftserver.HiveThriftServer2 \
--name "Thrift JDBC/ODBC Server" \
--executor-memory 1g \
spark-internal &>/dev/null &
}
lein-test() {
lein with-profile +ci test
}
......@@ -142,6 +169,22 @@ is_engine_enabled() {
[[ "$ENGINES" == *"$1"* ]]
}
# Make sure uberjar has less than 64k files because that is the Java 7 LIMIT
check-uberjar-file-count() {
if [ ! -f ./target/uberjar/metabase.jar ]; then
echo "Missing uberjar."
exit 1
fi
file_count=$(unzip -l target/uberjar/metabase.jar | wc -l)
echo "Uberjar has ${file_count} files."
if [ $file_count -gt 65535 ]; then
echo "Uberjar exceeds the 64k Java 7 file limit! We can't allow this. ¡Lo siento!"
exit 1
fi
}
# print a summary on exit
status=0
summary=""
......
......@@ -7,30 +7,66 @@ const fs = require("fs");
const _ = require("underscore");
const gParser = require("gettext-parser");
// NOTE: this function replace xgettext "{0}" style references with c-3po "${ 0 }" style references
function replaceReferences(str) {
return str.replace(/\{ *(\d+) *\}/g, "${ $1 }");
}
if (process.argv.length !== 4) {
console.log("USAGE: build-translation-frontend-resource input.po output.json");
console.log(
"USAGE: build-translation-frontend-resource input.po output.json"
);
process.exit(1);
}
const inputFile = process.argv[2];
const outputFile = process.argv[3];
console.log(`Compiling ${inputFile} for frontend...`);
const translationObject = gParser.po.parse(fs.readFileSync(inputFile, "utf-8"));
// NOTE: unsure why the headers are duplicated in a translation for "", but we don't need it
delete translationObject.translations[""][""]
delete translationObject.translations[""][""];
let fuzzyCount = 0;
let emptyCount = 0;
for (const id in translationObject.translations[""]) {
const translation = translationObject.translations[""][id];
if (!translation.comments.reference || _.any(translation.comments.reference.split("\n"), reference => reference.startsWith("frontend/"))) {
// remove comments:
delete translation.comments;
// NOTE: would be nice if we could remove the message id since it's redundant:
// delete translation.msgid;
} else {
// remove strings that aren't in the frontend
delete translationObject.translations[""][id];
const { reference, flag } = translation.comments || {};
// delete the translation, we'll add it back in if needed
delete translationObject.translations[""][id];
if (
// only include translations used on the frontend
!/(^|\n)frontend\//.test(reference)
) {
continue;
}
// don't include empty translations
if (_.isEqual(translation.msgstr, [""])) {
emptyCount++;
continue;
}
// don't include fuzzy translations
if (flag === "fuzzy") {
fuzzyCount++;
continue;
}
// remove comments
delete translation.comments;
// delete msgid since it's redundant, we have to add it back in on the frontend though
delete translation.msgid;
// replace references in translations
translation.msgstr = translation.msgstr.map(str => replaceReferences(str));
// replace references in msgid
translationObject.translations[""][replaceReferences(id)] = translation;
}
if (emptyCount > 0) {
console.warn(`+ Warning: removed ${emptyCount} empty translations`);
}
if (fuzzyCount > 0) {
console.warn(`+ Warning: removed ${fuzzyCount} fuzzy translations`);
}
fs.writeFileSync(outputFile, JSON.stringify(translationObject, null, 2), "utf-8");
fs.writeFileSync(outputFile, JSON.stringify(translationObject), "utf-8");
......@@ -9,7 +9,12 @@ fi
POT_NAME="locales/metabase.pot"
LOCALES=$(find locales -type f -name "*.po" -exec basename {} .po \;)
LOCALES_QUOTED=$(echo "$LOCALES" | awk '{ printf "\"%s\" ", $0 }')
if [ -z "$LOCALES" ]; then
LOCALES_QUOTED=""
else
LOCALES_QUOTED=" $(echo "$LOCALES" | awk '{ printf "\"%s\" ", $0 }')"
fi
FRONTEND_LANG_DIR="resources/frontend_client/app/locales"
......@@ -17,7 +22,7 @@ FRONTEND_LANG_DIR="resources/frontend_client/app/locales"
# NOTE: include "en" even though we don't have a .po file for it because it's the default?
cat << EOF > "resources/locales.clj"
{
:locales #{"en" $LOCALES_QUOTED}
:locales #{"en"$LOCALES_QUOTED}
:packages ["metabase"]
:bundle "metabase.Messages"
}
......
......@@ -25,6 +25,10 @@ mkdir -p "locales"
BABEL_ENV=extract ./node_modules/.bin/babel -q -x .js,.jsx -o /dev/null frontend/src
# BABEL_ENV=extract BABEL_DISABLE_CACHE=1 yarn run build
# NOTE: replace c-3po's "${ 0 }" style references with xgettext "{0}" style references for consistency
sed -i".bak" -E 's/\$\{ *([0-9]+) *\}/{\1}/g' "$POT_FRONTEND_NAME"
rm "$POT_FRONTEND_NAME.bak"
# update backend pot
# xgettext before 0.19 does not understand --add-location=file. Even CentOS
......@@ -48,7 +52,8 @@ find src -name "*.clj" | xgettext \
--add-comments --sort-by-file \
-o $POT_BACKEND_NAME -f -
sed -i "" -e 's/charset=CHARSET/charset=UTF-8/' "$POT_BACKEND_NAME"
sed -i".bak" 's/charset=CHARSET/charset=UTF-8/' "$POT_BACKEND_NAME"
rm "$POT_BACKEND_NAME.bak"
# merge frontend and backend pots
msgcat "$POT_FRONTEND_NAME" "$POT_BACKEND_NAME" > "$POT_NAME"
#!/usr/bin/env bash
VERSION="v0.29.0-snapshot"
VERSION="v0.29.1"
# dynamically pull more interesting stuff from latest git commit
HASH=$(git show-ref --head --hash=7 head) # first 7 letters of hash should be enough; that's what GitHub uses
......
......@@ -91,6 +91,13 @@ Another option is custom remapping, which is currently only possible for numeric
![Remapping form](./images/remapping/custom-mapping.png)
### Picking the filter UI for a field
Metabase will automatically try to pick the best kind of filter interface for each field based on that field's type and the number of different values in it. Fields with only a few possible choices, like a `Gender` field, will display a dropdown list by default when filtering on them; fields with more than 100 possible selections will show a search box with autocomplete.
If Metabase picked the wrong kind of filter UI for one of your fields, you can manually change it. You can choose from a drop down list, a search box, or just a plain input box:
![Filter options](./images/filter-options.png)
---
......
docs/administration-guide/images/filter-options.png

92 KiB

......@@ -6,7 +6,7 @@ In this guide, we'll discuss how Metabase is built. This should give you a good
## What we're trying to build
Metabase is all about letting non-technical users get access to the their organization's data. We're trying to maximize the amount of power that can be comfortably used by someone who understands their business, is quantitatively bent, but probably only comfortable with Excel.
Metabase is all about letting non-technical users get access to the their organization's data. We're trying to maximize the amount of power that can be comfortably used by someone who understands their business, is quantitatively bent, but probably only comfortable with Excel.
It's important to keep in mind these goals of the Metabase project. Many times
proposals will be marked "Out of Scope" or otherwise deprioritized. This doesn't mean the proposal isn't useful, or that we wouldn't be interested in seeing it done as a side project or as an experimental branch. However, it does mean that we won't point the core team or contributors to it in the near term. Issues that are slightly out of scope will be kept open in case there is community support (and ideally contributions).
......@@ -15,7 +15,7 @@ To get a sense for the end goals, make sure to read the [Zen of Metabase](../zen
## Our product process:
The core team runs a pretty well defined product process. It is actively being tweaked, but the below is a pretty faithful description of it at the time of writing. You should have a clear idea of how we work before jumping in with a PR.
The core team runs a pretty well defined product process. It is actively being tweaked, but the below is a pretty faithful description of it at the time of writing. You should have a clear idea of how we work before jumping in with a PR.
### A) Identify product needs from the community
......@@ -29,22 +29,25 @@ We typically will collect a group of issues or suggestions into a new topline fe
Once a feature has been defined, typically it will be taken on by a product designer. Here, they will produce low fi mocks, get feedback from our users and community, and iterate.
Once the main UX flows have been dialed in, there will be a hi-fidelity visual design.
Once the main UX flows have been dialed in, there will be a hi-fidelity visual design.
Features that are ready for design are are tagged [Design Needed](https://github.com/metabase/metabase/labels/Design%2FNeeded). Once a feature has had a reasonably complete visual design it should be tagged [Help Wanted](https://github.com/metabase/metabase/labels/Help%20Wanted).
### D) Build the feature
Once a feature is tagged [Help Wanted](https://github.com/metabase/metabase/labels/Help%20Wanted), it is considered ready to be built. A core team member (or you, awesomely helpful person that you are) can start working on it.
Once one or more people have started to work on a feature, it should be marked [In Progress](https://github.com/metabase/metabase/labels/In%20Progress). Once there is a branch+some code, a pull request is opened, linked to the feature + any issues that were pulled together to inform the feature.
If you're building something that users will see in Metabase, please refer to the [Style Guide](https://localhost:3000/_internal) while running the development environment to learn how and when to use various Metabase UI elements.
Once one or more people have started to work on a feature, it should be marked [In Progress](https://github.com/metabase/metabase/labels/In%20Progress). Once there is a branch+some code, a pull request is opened, linked to the feature + any issues that were pulled together to inform the feature.
### E) Verification and merging
All PRs that involve more than an insignificant change should be reviewed. See our [Code Review Process](code-reviews.md).
If all goes well, the feature gets coded up, verified and then the pull request gets merged! High-fives all around.
If there are tests missing, code style concerns or specific architectural issues in the pull request, they should be fixed before merging. We have a very high bar on both code and product quality and it's important that this be maintained going forward, so please be patient with us here.
If all goes well, the feature gets coded up, verified and then the pull request gets merged! High-fives all around.
If there are tests missing, code style concerns or specific architectural issues in the pull request, they should be fixed before merging. We have a very high bar on both code and product quality and it's important that this be maintained going forward, so please be patient with us here.
## Ways to help:
......@@ -72,14 +75,14 @@ By our definition, "Bugs" are situations where the program doesn't do what it wa
There are a lot of docs. We often have difficulties keeping them up to date. If you are reading them and you notice inconsistencies, errors or outdated information, please help up keep them current!
### Working on features
### Working on features
Some features, eg Database drivers, don't have any user facing pixels. These are a great place to start off contributing as they don't require as much communication, discussions about tradeoffs and process in general.
Some features, eg Database drivers, don't have any user facing pixels. These are a great place to start off contributing as they don't require as much communication, discussions about tradeoffs and process in general.
In situations where a design has already been done, we can always use some help. Chime in on a pull request or an issue and offer to help.
In situations where a design has already been done, we can always use some help. Chime in on a pull request or an issue and offer to help.
Generally speaking, any issue in [Help Wanted](https://github.com/metabase/metabase/labels/Help%20Wanted) is fair game.
### #YOLO JUST SUBMIT A PR
If you come up with something really cool, and want to share it with us, just submit a PR. If it hasn't gone through the above process, we probably won't merge it as is, but if it's compelling, we're more than willing to help you via code review, design review and generally OCD nitpicking so that it fits into the rest of our codebase.
If you come up with something really cool, and want to share it with us, just submit a PR. If it hasn't gone through the above process, we probably won't merge it as is, but if it's compelling, we're more than willing to help you via code review, design review and generally OCD nitpicking so that it fits into the rest of our codebase.
......@@ -124,6 +124,7 @@ Integration tests use an enforced file naming convention `<test-suite-name>.inte
Useful commands:
```bash
./bin/build version uberjar # Builds the JAR without frontend assets; run this every time you need to update the backend
lein run refresh-integration-test-db-metadata # Scan the sample dataset and re-run sync/classification/field values caching
yarn run test-integrated-watch # Watches for file changes and runs the tests that have changed
yarn run test-integrated-watch -- TestFileName # Watches the files in paths that match the given (regex) string
```
......@@ -265,7 +266,8 @@ Start up an instant cheatsheet for the project + dependencies by running
lein instant-cheatsheet
## Internationalization
We are an application with lots of users all over the world. To help them use Metabase in their own language, we mark all of our strings as i18n. The general workflow is:
We are an application with lots of users all over the world. To help them use Metabase in their own language, we mark all of our strings as i18n.
### The general workflow for developers is:
1. Tag strings in the frontend using `t` and `jt` ES6 template literals (see more details in https://c-3po.js.org/):
......@@ -281,10 +283,16 @@ and in the backend using `trs` and related macros (see more details in https://g
```
2. When you have added/edited tagged strings in the code, run `./bin/i18n/update-translations` to update the base `locales/metabase.pot` template and each existing `locales/LOCALE.po`
3. To add a new translaction run `./bin/i18n/update-translation LOCALE`
4. Edit translation in `locales/LOCALE.po`
5. Run `./bin/i18n/build-translation-resources` to compile translations for frontend and backend
6. Restart or rebuild Metabase
### The workflow for translators in starting a new translation, or editing an existing one:
1. You should run `./bin/i18n/update-translations` first to ensure the latest strings have been extracted.
2. If you're starting a new translation or didn't run update-translations then run `./bin/i18n/update-translation LOCALE`
3. Edit ./locales/LOCALE.po
4. `Run ./bin/i18n/build-translation-resources`
5. Restart or rebuild Metabase, Test, repeat 2 and 3
6. Commit changes to ./locales/LOCALE.po and ./resources/frontend_client/app/locales/LOCALE.json
To try it out, change your browser's language (e.x. chrome://settings/?search=language) to one of the locales to see it working. Run metabase with the `JAVA_TOOL_OPTIONS=-Duser.language=LOCALE` environment variable set to set the locale on the backend, e.x. for pulses and emails (eventually we'll also add a setting in the app)
......
......@@ -104,7 +104,7 @@ In `/etc/init.d/metabase`, replace configurable items (they look like `<some-var
uninstall)
uninstall
;;
retart)
restart)
stop
start
;;
......
......@@ -26,11 +26,11 @@ The rest of this guide will follow each phase of the Elastic Beanstalk setup ste
### New Application
You should now see a screen that looks like
You should now see a screen that looks like
![Elastic Beanstalk First Screen](images/EBFirstScreen.png)
NOTE: If this screenshot does not match what you see in the Elastic Beanstalk console, it is likely that you are on an old version of the Elastic Beanstalk UI. At the time of writing this documentation, both versions of the UI are being reported in the wild. You can view our older documenatation [here](running-metabase-on-elastic-beanstalk-old.md)
NOTE: If this screenshot does not match what you see in the Elastic Beanstalk console, it is likely that you are on an old version of the Elastic Beanstalk UI. At the time of writing this documentation, both versions of the UI are being reported in the wild. You can view our older documentation [here](running-metabase-on-elastic-beanstalk-old.md)
Elastic Beanstalk is organized into Applications and Environments, so to get started we must create a new Application. Enter the application name `Metabase` and continue by clicking `Next`.
......@@ -52,7 +52,7 @@ And of course if you don't care about the URL you can simply leave it to whateve
### New Environment
Elastic Beanstalk provides two choices for environments within an Application, but you should leave the setting to `Web Server` on that landing page.
Elastic Beanstalk provides two choices for environments within an Application, but you should leave the setting to `Web Server` on that landing page.
![ebnewenv](images/EBWebTier.png)
......@@ -80,7 +80,7 @@ You will need to enable enhanced health checks for your Beanstalk Monitoring.
Click on the `modify` link under the Monitoring section as below.
![Elastic Beanstalk Monitoring](images/EBMonitoringSelect.png)
Then make sure enhanced health checks are enabled. This is a free option, unless you later add specific metrics to CloudWatch.
Then make sure enhanced health checks are enabled. This is a free option, unless you later add specific metrics to CloudWatch.
![Elastic Beanstalk Monitoring Settings](images/EBMonitoringSettings.png)
......@@ -95,7 +95,7 @@ To set the database password from the Beanstalk template, hit "Review and Launch
![Elastic Beanstalk Database Configuration Options](images/EBDatabaseConfigurationOptions.png)
Once there, enter a database username and password. We suggest you hold onto this in a password manager, as it can be useful for things like backups or troubleshooting.
Once there, enter a database username and password. We suggest you hold onto this in a password manager, as it can be useful for things like backups or troubleshooting.
![Elastic Beanstalk Database Settings](images/EBDatabaseSettings.png)
......
......@@ -11,7 +11,9 @@ If you've got a Heroku account then all there is to do is follow this one-click
[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.svg)](http://downloads.metabase.com/launch-heroku.html)
This will launch a Heroku deployment using a github repository that Metabase maintains.
This will launch a Heroku deployment using a GitHub repository that Metabase maintains.
It should only take a few minutes for Metabase to start. You can check on the progress by viewing the logs at [https://dashboard.heroku.com/apps/YOUR_APPLICATION_NAME/logs](https://dashboard.heroku.com/apps/YOUR_APPLICATION_NAME/logs) or using the Heroku command line tool with the `heroku logs -t -a YOUR_APPLICATION_NAME` command.
### Upgrading beyond the `Free` tier
......@@ -27,6 +29,7 @@ Heroku is very kind and offers a free tier to be used for very small/non-critica
* Heroku’s 30 second timeouts on all web requests can cause a few issues if you happen to have longer running database queries. Most people don’t run into this but be aware that it’s possible.
* When using the `free` tier, if you don’t access the application for a while Heroku will sleep your Metabase environment. This prevents things like Pulses and Metabase background tasks from running when scheduled and at times makes the app appear to be slow when really it's just Heroku reloading your app. You can resolve this by upgrading to the `hobby` tier or higher.
* Sometimes Metabase may run out of memory and you will see messages like `Error R14 (Memory quota exceeded)` in the Heroku logs. If this happens regularly we recommend upgrading to the `standard-2x` tier dyno.
Now that you’ve installed Metabase, it’s time to [set it up and connect it to your database](../setting-up-metabase.md).
......
......@@ -12,6 +12,7 @@
* [Changing password complexity](#changing-metabase-password-complexity)
* [Handling Timezones](#handling-timezones-in-metabase)
* [Configuring Emoji Logging](#configuring-emoji-logging)
* [Configuring Logging Level](#configuring-logging-level)
* [How to setup monitoring via JMX](#monitoring-via-jmx)
* [A word on Java versions](#java-versions)
......@@ -81,6 +82,7 @@ The application database is where Metabase stores information about users, saved
**NOTE:** currently Metabase does not provide automated support for migrating data from one application database to another, so if you start with H2 and then want to move to Postgres you'll have to dump the data from H2 and import it into Postgres before relaunching the application.
#### [H2](http://www.h2database.com/) (default)
To use the H2 database for your Metabase instance you don't need to do anything at all. When the application is first launched it will attempt to create a new H2 database in the same filesystem location the application is launched from.
You can see these database files from the terminal:
......@@ -98,6 +100,7 @@ If for any reason you want to use an H2 database file in a separate location fro
export MB_DB_FILE=/the/path/to/my/h2.db
java -jar metabase.jar
Note that H2 automatically appends `.mv.db` or `.h2.db` to the path you specify; do not include those in you path! In other words, `MB_DB_FILE` should be something like `/path/to/metabase.db`, rather than something like `/path/to/metabase.db.mv.db` (even though this is the file that actually gets created).
#### [Postgres](http://www.postgresql.org/)
......@@ -132,13 +135,13 @@ This will tell Metabase to look for its application database using the supplied
# Migrating from using the H2 database to MySQL or Postgres
If you decide to use the default application database (H2) when you initially start using Metabase, but decide later that you'd like to switch to a more production ready database such as MySQL or Postgres we make the transition easy for you.
If you decide to use the default application database (H2) when you initially start using Metabase, but later decide that you'd like to switch to a more production-ready database such as MySQL or Postgres, we make the transition easy for you.
Metabase provides a custom migration command for upgrading H2 application database files by copying their data to a new database. Here's what you'll want to do:
1. Shutdown your Metabase instance so that it's not running. This ensures no accidental data gets written to the db while migrating.
2. Make a backup copy of your H2 application database by following the instructions in [Backing up Metabase Application Data](#backing-up-metabase-application-data). Safety first!
3. Run the Metabase data migration command using the appropriate environment variables for the target database you want to migrate to. You can find details about specifying MySQL and Postgres databases at [Configuring the application database](#configuring-the-metabase-application-database). Here's an example of migrating to Postgres.
3. Run the Metabase data migration command using the appropriate environment variables for the target database you want to migrate to. You can find details about specifying MySQL and Postgres databases at [Configuring the application database](#configuring-the-metabase-application-database). Here's an example of migrating to Postgres:
```
export MB_DB_TYPE=postgres
......@@ -147,20 +150,21 @@ export MB_DB_PORT=5432
export MB_DB_USER=<username>
export MB_DB_PASS=<password>
export MB_DB_HOST=localhost
java -jar metabase.jar load-from-h2 <path-to-metabase-h2-database-file>
java -jar metabase.jar load-from-h2 /path/to/metabase.db # do not include .mv.db or .h2.db suffix
```
It is expected that you will run the command against a brand new (empty!) database and Metabase will handle all of the work of creating the database schema and migrating the data for you.
It is expected that you will run the command against a brand-new (empty!) database; Metabase will handle all of the work of creating the database schema and migrating the data for you.
###### Notes
* It is required that wherever you are running this migration command can connect to the target MySQL or Postgres database. So if you are attempting to move the data to a cloud database make sure you take that into consideration.
* It is required that you can connect to the target MySQL or Postgres database in whatever environment you are running this migration command in. So, if you are attempting to move the data to a cloud database, make sure you take that into consideration.
* The code that handles these migrations uses a Postgres SQL command that is only available in Postgres 9.4 or newer versions. Please make sure you Postgres database is version 9.4 or newer.
* H2 automatically adds a `.h2.db` or `.mv.db` extension to the database path you specify, so make sure the path to the DB file you pass to the command *does not* include it. For example, if you have a file named `/path/to/metabase.db.h2.db`, call the command with `load-from-h2 /path/to/metabase.db`.
# Running Metabase database migrations manually
When Metabase is starting up it will typically attempt to determine if any changes are required to the application database and it will execute those changes automatically. If for some reason you wanted to see what these changes are and run them manually on your database then we let you do that.
When Metabase is starting up, it will typically attempt to determine if any changes are required to the application database, and, if so, will execute those changes automatically. If for some reason you wanted to see what these changes are and run them manually on your database then we let you do that.
Simply set the following environment variable before launching Metabase:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment