Skip to content
This repository was archived by the owner on Sep 13, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
0d88051
feat: add cli `--migrationCollection` option for specifying the colle…
jackall3n Aug 8, 2023
0091e2c
Use more appropriate test
jackall3n Aug 8, 2023
4ef3bf5
Updated option name
jackall3n Aug 8, 2023
47c13dd
update to fireblaze
jackall3n Mar 14, 2024
d706488
README pdate
jackall3n Mar 14, 2024
6b7c3f5
Updated types
jackall3n Mar 14, 2024
8ba6f51
version
jackall3n Mar 14, 2024
3915d34
Updated README.md
jackall3n Mar 14, 2024
aa10bb0
Migrate to PNPM
jackall3n Mar 14, 2024
8cfb9ac
Migrate to PNPM
jackall3n Mar 14, 2024
d3183c4
Migrate to PNPM
jackall3n Mar 14, 2024
f018a7e
Add changeset workflow
jackall3n Mar 14, 2024
8cbe47b
Create dependabot.yml
jackall3n Mar 14, 2024
e2c747b
Run tests in CI
jackall3n Mar 14, 2024
b6155d0
erge branch 'master' of github.com:jackall3n/fireway
jackall3n Mar 14, 2024
1bbe4b7
Update to master
jackall3n Mar 14, 2024
6b13c93
Update workflows node version
jackall3n Mar 14, 2024
df7ed99
lock
jackall3n Mar 14, 2024
7b661d4
updated test
jackall3n Mar 14, 2024
6b5d2bb
pretest
jackall3n Mar 14, 2024
2467e35
git status
jackall3n Mar 14, 2024
bcbe4bc
git check
jackall3n Mar 14, 2024
44e215d
setup pnpm
jackall3n Mar 14, 2024
845b773
name
jackall3n Mar 14, 2024
d20765f
permissions
jackall3n Mar 14, 2024
b19bbac
permissions
jackall3n Mar 14, 2024
fcbd396
updated pr workflow
jackall3n Mar 14, 2024
ffbf8c4
Bump @google-cloud/firestore from 5.0.2 to 7.3.1
dependabot[bot] Mar 14, 2024
9d399d7
run tests
jackall3n Mar 14, 2024
f4742b8
Merge pull request #11 from jackall3n/dependabot/npm_and_yarn/google-…
jackall3n Mar 14, 2024
a1700ca
Update dependabot.yml
jackall3n Mar 14, 2024
f452d0d
Bump jose from 2.0.5 to 2.0.7
dependabot[bot] Mar 14, 2024
40da9ce
Bump ip from 1.1.5 to 1.1.9
dependabot[bot] Mar 14, 2024
b6c9470
Bump semver from 7.3.7 to 7.6.0
dependabot[bot] Mar 14, 2024
de06bce
Bump tape from 4.13.3 to 5.7.5
dependabot[bot] Mar 14, 2024
8701557
Bump follow-redirects from 1.14.8 to 1.15.5
dependabot[bot] Mar 14, 2024
23f2c6e
Merge pull request #10 from jackall3n/dependabot/npm_and_yarn/semver-…
jackall3n Mar 14, 2024
3c9578e
Merge pull request #9 from jackall3n/dependabot/npm_and_yarn/jose-2.0.7
jackall3n Mar 14, 2024
3670233
Merge pull request #8 from jackall3n/dependabot/npm_and_yarn/follow-r…
jackall3n Mar 14, 2024
09f7220
Merge pull request #7 from jackall3n/dependabot/npm_and_yarn/ip-1.1.9
jackall3n Mar 14, 2024
de95569
Merge pull request #4 from jackall3n/dependabot/npm_and_yarn/tape-5.7.5
jackall3n Mar 14, 2024
b1f1651
Bump typescript from 4.6.4 to 5.4.2
dependabot[bot] Mar 14, 2024
3b4df98
Bump firebase-tools from 10.7.2 to 13.5.0
dependabot[bot] Mar 14, 2024
4d01941
changeset command
jackall3n Mar 14, 2024
7b192bd
changeset command
jackall3n Mar 14, 2024
4f0ccc0
Merge pull request #14 from jackall3n/dependabot/npm_and_yarn/typescr…
jackall3n Mar 14, 2024
e807af0
Merge pull request #12 from jackall3n/dependabot/npm_and_yarn/firebas…
jackall3n Mar 14, 2024
2a655a5
Bump qs from 6.5.2 to 6.5.3
dependabot[bot] Mar 14, 2024
61bd1c2
changeset
jackall3n Mar 14, 2024
7228b66
Merge branch 'master' of github.com:jackall3n/fireblaze
jackall3n Mar 14, 2024
f0a1f83
Bump ts-node from 10.7.0 to 10.9.2
dependabot[bot] Mar 14, 2024
567a001
Bump firebase-admin from 10.1.0 to 12.0.0
dependabot[bot] Mar 14, 2024
56db028
Merge pull request #16 from jackall3n/dependabot/npm_and_yarn/qs-6.5.3
jackall3n Mar 14, 2024
103c413
Merge pull request #15 from jackall3n/dependabot/npm_and_yarn/firebas…
jackall3n Mar 14, 2024
a4d9fd9
Merge pull request #13 from jackall3n/dependabot/npm_and_yarn/ts-node…
jackall3n Mar 14, 2024
7781b01
Bump ansi-regex from 4.1.0 to 4.1.1
dependabot[bot] Mar 14, 2024
cb55698
Version Packages
github-actions[bot] Mar 14, 2024
07ea37d
Bump start-server-and-test from 1.14.0 to 2.0.3
dependabot[bot] Mar 14, 2024
cca95f6
Merge pull request #17 from jackall3n/changeset-release/master
jackall3n Mar 14, 2024
c383743
Merge pull request #18 from jackall3n/dependabot/npm_and_yarn/ansi-re…
jackall3n Mar 14, 2024
fa04f53
Merge pull request #6 from jackall3n/dependabot/npm_and_yarn/start-se…
jackall3n Mar 14, 2024
d99c582
Update packages
jackall3n Mar 14, 2024
3ae5f2d
Version Packages
github-actions[bot] Mar 14, 2024
2325d0a
Merge pull request #19 from jackall3n/changeset-release/master
jackall3n Mar 14, 2024
d11594a
Bump protobufjs from 6.11.2 to 6.11.4
dependabot[bot] Mar 14, 2024
bdebefb
Merge pull request #20 from jackall3n/dependabot/npm_and_yarn/protobu…
jackall3n Mar 14, 2024
e334cf2
Update packages
jackall3n Mar 14, 2024
d0f2e5e
Update packages
jackall3n Mar 14, 2024
6565e40
Update packages
jackall3n Mar 14, 2024
2c23924
Update packages
jackall3n Mar 14, 2024
d592a60
Update packages
jackall3n Mar 14, 2024
ae82cc4
Version Packages
github-actions[bot] Mar 14, 2024
7d4c731
Merge pull request #21 from jackall3n/changeset-release/master
jackall3n Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
58 changes: 58 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Changesets
on:
push:
branches:
- master

env:
CI: true

jobs:
version:
timeout-minutes: 15
runs-on: ubuntu-latest

permissions:
contents: "write"
id-token: "write"
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- name: Setup npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Install packages
run: pnpm install

- name: Run tests
run: pnpm test

- run: git status

- name: create and publish versions
uses: changesets/action@v1
with:
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: PR

on:
pull_request:
branches:
- master

env:
CI: true

jobs:
run-tests:
name: Run tests
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- name: Install packages
run: pnpm install

- name: Install packages
run: pnpm install

- name: Run tests
run: pnpm test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ typings/

# next.js build output
.next

# ide configurations
.idea
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# fireblaze

## 1.4.0

### Minor Changes

- 6565e40: Updated packages
- e334cf2: Updated packages versions

### Patch Changes

- d592a60: Updated packages

## 1.3.0

### Minor Changes

- d99c582: Updated packages

## 1.2.2

### Patch Changes

- 61bd1c2: Update packages

## 1.2.1

### Patch Changes

- Update to PNPM
72 changes: 37 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# fireway
A schema migration tool for firestore heavily inspired by [flyway](https://flywaydb.org/)
# fireblaze
A fork of the useful (but seemly dead) project [fireway](https://github.com/kevlened/fireway)

## Install

```bash
yarn global add fireway
yarn global add fireblaze

# or

npx fireway
npx fireblaze
```

## Credentials

In order to fireway be able to connect to firestore you need to set up the environment variable `GOOGLE_APPLICATION_CREDENTIALS` with service account file path.
In order to fireblaze be able to connect to firestore you need to set up the environment variable `GOOGLE_APPLICATION_CREDENTIALS` with service account file path.

Example:
```bash
Expand All @@ -24,47 +24,49 @@ export GOOGLE_APPLICATION_CREDENTIALS="path/to/firestore-service-account.json"

```bash
Usage
$ fireway <command> [options]
$ fireblaze <command> [options]

Available Commands
migrate Migrates schema to the latest version

For more info, run any command with the `--help` flag
$ fireway migrate --help
$ fireblaze migrate --help

Options
--require Requires a module before executing
-v, --version Displays current version
-h, --help Displays this message

Examples
$ fireway migrate
$ fireway --require="ts-node/register" migrate
$ fireblaze migrate
$ fireblaze --require="ts-node/register" migrate
```

### `fireway migrate`
### `fireblaze migrate`
```bash
Description
Migrates schema to the latest version

Usage
$ fireway migrate [options]
$ fireblaze migrate [options]

Options
--path Path to migration files (default ./migrations)
--projectId Target firebase project
--dryrun Simulates changes
--forceWait Forces waiting for migrations that do not strictly manage async calls
--require Requires a module before executing
-h, --help Displays this message
--path Path to migration files (default ./migrations)
--projectId Target firebase project
--dryrun Simulates changes
--forceWait Forces waiting for migrations that do not strictly manage async calls
--require Requires a module before executing
--migrationsCollection Firestore collection to store migration state (default fireblaze)
-h, --help Displays this message

Examples
$ fireway migrate
$ fireway migrate --path=./my-migrations
$ fireway migrate --projectId=my-staging-id
$ fireway migrate --dryrun
$ fireway migrate --forceWait
$ fireway --require="ts-node/register" migrate
$ fireblaze migrate
$ fireblaze migrate --path=./my-migrations
$ fireblaze migrate --projectId=my-staging-id
$ fireblaze migrate --dryrun
$ fireblaze migrate --forceWait
$ fireblaze migrate --migrationsCollection=migrations
$ fireblaze --require="ts-node/register" migrate
```

## Migration file format
Expand Down Expand Up @@ -103,52 +105,52 @@ For type checking and Intellisense, there are two options:
```ts
// ./migrations/v0.0.1__typescript-example.ts

import { MigrateOptions } from 'fireway';
import { MigrateOptions } from 'fireblaze';

export async function migrate({firestore} : MigrateOptions) {
await firestore.collection('data').doc('one').set({key: 'value'});
};
```
4. Run `fireway migrate` with the `require` option
4. Run `fireblaze migrate` with the `require` option

```sh
$ fireway migrate --require="ts-node/register"
$ fireblaze migrate --require="ts-node/register"
```

### JSDoc

Alternatively, you can use [JSDoc](https://jsdoc.app/) for Intellisense

```js
/** @param { import('fireway').MigrateOptions } */
/** @param { import('fireblaze').MigrateOptions } */
module.exports.migrate = async ({firestore}) => {
// Intellisense is enabled
};
```

## Running locally

Typically, `fireway` expects a `--projectId` option that lets you specify the Firebase project associated with your Firestore instance against which it performs migrations.
Typically, `fireblaze` expects a `--projectId` option that lets you specify the Firebase project associated with your Firestore instance against which it performs migrations.
However, most likely you'll want to test your migration scripts _locally_ first before running them against your actual (presumably, production) instances.
If you are using the [Firestore emulator](https://firebase.google.com/docs/emulator-suite/connect_firestore), define the FIRESTORE_EMULATOR_HOST environment variable, e.g.:

`export FIRESTORE_EMULATOR_HOST="localhost:8080"`

The firestore node library will connect to your local instance. This way, you don't need a project ID and migrations will be run against your emulator instance. This works since `fireway` is built on the [firestore node library](https://www.npmjs.com/package/@google-cloud/firestore).
The firestore node library will connect to your local instance. This way, you don't need a project ID and migrations will be run against your emulator instance. This works since `fireblaze` is built on the [firestore node library](https://www.npmjs.com/package/@google-cloud/firestore).

## Migration logic

1. Gather all the migration files and sort them according to semver
2. Find the last migration in the `fireway` collection
2. Find the last migration in the `fireblaze` collection
3. If the last migration failed, stop. (remove the failed migration result or restore the db to continue)
4. Run the migration scripts since the last migration

## Migration results

Migration results are stored in the `fireway` collection in `firestore`
Migration results are stored in the `fireblaze` collection in `firestore`

```js
// /fireway/3-0.0.1-example
// /fireblaze/3-0.0.1-example

{
checksum: 'fdfe6a55a7c97a4346cb59871b4ce97c',
Expand All @@ -168,11 +170,11 @@ Migration results are stored in the `fireway` collection in `firestore`

```bash
# To install packages and firestore emulator
$ yarn
$ yarn setup
$ pnpm
$ pnpm setup

# To run tests
$ yarn test
$ pnpm test
```

## License
Expand Down
1 change: 1 addition & 0 deletions fireway.d.ts → fireblaze.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export interface MigrateOptions {
FieldPath: typeof import("@google-cloud/firestore").FieldPath;
Timestamp: typeof import("@google-cloud/firestore").Timestamp;
dryrun: boolean;
migrationsCollection: string;
}
Loading