Skip to content

Commit

Permalink
Merge pull request #11 from halvardssm/read-remote-file
Browse files Browse the repository at this point in the history
fixed issue with reading remote file
  • Loading branch information
halvardssm authored Apr 30, 2020
2 parents f7fe232 + 14da22d commit bf830aa
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CONFIG_FILE=./tests/config/mysql.config.ts
DB_URL=postgres://${DB_USER}:${DB_PWD@localhost:${DB_PG_PORT}/${DB_NAME}

migration-%:
deno run --allow-write --allow-read cli.ts make $* -c ${CONFIG_FILE}
deno run --allow-write --allow-read --allow-net cli.ts make $* -c ${CONFIG_FILE}
migrate:
deno run --allow-net --allow-read cli.ts migrate -c ${CONFIG_FILE}
rollback:
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ If you have a database system you would like to see in this list, feel free to m

* `make [name]`: Create migration

```deno run --allow-read --allow-write https://deno.land/x/nessie/cli.ts make create_users```
```deno run --allow-net --allow-read --allow-write https://deno.land/x/nessie/cli.ts make create_users```

* `migrate`: Run migration - will migrate all migrations in your migration folder (sorted by timestamp) newer than the latest migration in your db

```deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts migrate```
```deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts migrate -c ./nessie.config.ts```
```deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts migrate```

```deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts migrate -c ./nessie.config.ts```

* `rollback`: Rollback - will rollback the latest migration

```deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts rollback```
```deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts rollback```

### Flags

Expand Down
14 changes: 9 additions & 5 deletions cli/state.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { _nessieConfig, nessieConfig } from "../nessie.config.ts";
import { Denomander } from "../deps.ts";
import {
MySQLClient,
ClientConfig,
PGClient,
open,
IConnectionParams,
stdConfig,
Denomander,
} from "../deps.ts";
import { dbDialects } from "../mod.ts";
import { PGSQL } from "./pgsql.ts";
import { ClientTypes, ClientI } from "./utils.ts";
import { MySQL } from "./mysql.ts";
import { SQLite } from "./sqlite.ts";
import StdConfig from "../nessie.config.ts";

export class State {
private enableDebug: boolean;
Expand All @@ -32,7 +32,7 @@ export class State {
}

async init() {
let config: nessieConfig = StdConfig;
let config: nessieConfig = stdConfig;

try {
const rawConfig = await import(
Expand Down Expand Up @@ -65,9 +65,13 @@ export class State {

await Deno.mkdir(this.migrationFolder, { recursive: true });

await Deno.copyFile(
"./src/templates/migration.ts",
const responseFile = await fetch(
"https://deno.land/x/nessie/cli/templates/migration.ts",
);

await Deno.writeTextFile(
`${this.migrationFolder}/${fileName}`,
await responseFile.text(),
);

console.info(`Created migration ${fileName} at ${this.migrationFolder}`);
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Denomander from "https://deno.land/x/[email protected]/mod.ts";
import stdConfig from "https://deno.land/x/nessie/nessie.config.ts";

export { Denomander };
export { Denomander, stdConfig };
export {
Client as MySQLClient,
ClientConfig,
Expand All @@ -11,7 +12,7 @@ export {
DB as SQLiteClient,
save,
open,
} from "https://deno.land/x/sqlite/mod.ts";
} from "https://deno.land/x/sqlite@v0.1.0/mod.ts";
export {
assertEquals,
assert,
Expand Down
8 changes: 4 additions & 4 deletions nessie.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface _nessieConfig {
}

const configPg: nessieConfig = {
migrationFolder: `${Deno.cwd()}/tests/migrations`,
migrationFolder: `${Deno.cwd()}/migrations`,
connection: {
host: "localhost",
port: "5000",
Expand All @@ -38,7 +38,7 @@ const configPg: nessieConfig = {
};

const configMySql: nessieConfig = {
migrationFolder: `${Deno.cwd()}/tests/migrations`,
migrationFolder: `${Deno.cwd()}/migrations`,
connection: {
hostname: "localhost",
port: 5001,
Expand All @@ -50,8 +50,8 @@ const configMySql: nessieConfig = {
};

const configSqLite: nessieConfig = {
migrationFolder: `${Deno.cwd()}/tests/migrations`,
connection: `tests/data/sqlite.db`,
migrationFolder: `${Deno.cwd()}/migrations`,
connection: "sqlite.db",
dialect: "sqlite",
};

Expand Down

0 comments on commit bf830aa

Please sign in to comment.