我有一个正在运行的GitHub操作,可安装PostgreSQL11。但是现在我使用了UUID,但不支持这些UUID。
我需要运行CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
来安装UUID,但不清楚如何使用GitHub Actions来执行此操作。
我已经尝试并尝试了其他几个启用了UUID支持的Docker映像,但是它们总是老用户抛出的,不支持Actions。
我的Rust.yml
在下面:
name: Rust
on: [push]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
rust: [stable, beta]
services:
postgres:
image: postgres:11.6
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
RUSTFLAGS: -D warnings
CARGO_INCREMENTAL: 0
RUN_SLOW_TESTS: 1
RUSTUP_MAX_RETRIES: 10
CARGO_NET_RETRY: 10
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
components: rustfmt
targets: wasm32-unknown-unknown
- uses: actions/checkout@master
- name: Install Dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install libudev-dev zlib1g-dev alsa libasound2-dev
- name: Build
run: cargo build --verbose
- name: Install Diesel CLI
run: cargo install diesel_cli --no-default-features --features postgres
- name: Setup Diesel
env:
DATABASE_URL: postgres://postgres:postgres@localhost/nof1_time_series
run: diesel setup
- name: Run tests
env:
DATABASE_URL: postgres://postgres:postgres@localhost/nof1_time_series
run: cargo test --verbose
解决方案是将以下/migrations/00000000000010_install_uuid_feature/Up.sql
作为自己的迁移包含在迁移集中,并以超级用户postgres
身份运行:
-- Install the UUID extension to this database
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
如果您将Rust Diesel用作ORM,则还有其他UUID提示:
[dependencies]
diesel = { version = "1.4", features = ["postgres", "chrono", "uuidv07", "serde_json"] }
uuid = {version = "0.8", features = ["serde", "v4"]}
chrono = { version = "0.4", features = ["serde"] }
name: Rust
on: [push]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
rust: [stable, beta]
services:
postgres:
image: postgres:11.6
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
RUSTFLAGS: -D warnings
CARGO_INCREMENTAL: 0
RUN_SLOW_TESTS: 1
RUSTUP_MAX_RETRIES: 10
CARGO_NET_RETRY: 10
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
components: rustfmt
targets: wasm32-unknown-unknown
- uses: actions/checkout@master
- name: Install Dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install libudev-dev zlib1g-dev alsa libasound2-dev
- name: Build
run: cargo build --verbose
- name: Install Diesel CLI
run: cargo install diesel_cli --no-default-features --features postgres
- name: Setup Diesel
env:
DATABASE_URL: postgres://postgres:postgres@localhost/timeseries
run: diesel setup
- name: Run tests
env:
DATABASE_URL: postgres://postgres:postgres@localhost/timeseries
run: cargo test --verbose