Skip to content

Commit

Permalink
Merge pull request #1 from muhsinkamil/initial-setup
Browse files Browse the repository at this point in the history
Initial setup
  • Loading branch information
muhsinkamil authored Dec 18, 2021
2 parents ead7b3b + d3de564 commit c4682ed
Show file tree
Hide file tree
Showing 11 changed files with 2,545 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
3 changes: 3 additions & 0 deletions .sampleenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BASE_PATH=http://localhost:3000
APP_PORT=3000
ENVIRONMENT=development
14 changes: 14 additions & 0 deletions db/migrations/20211218122321_create_user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Knex } from "knex";

export async function up(knex: Knex): Promise<void> {
return knex.schema.createTable("users", (table) => {
table.increments();
table.string("first_name");
table.string("last_name");
table.timestamps(true, true);
});
}

export async function down(knex: Knex): Promise<void> {
return knex.schema.dropTableIfExists("users");
}
53 changes: 53 additions & 0 deletions knexfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Update with your config settings. Made with command "knex init -x ts"

export default {
development: {
client: "postgresql",
connection: {
database: "graphql_typed_db",
user: "graphql_typed_user",
password: "graphql_typed_password",
},
pool: {
min: 2,
max: 10,
},
migrations: {
directory: "./db/migrations",
},
},

staging: {
client: "postgresql",
connection: {
database: "my_db",
user: "username",
password: "password",
},
pool: {
min: 2,
max: 10,
},
migrations: {
directory: "./db/migrations",
// tableName: "knex_migrations",
},
},

production: {
client: "postgresql",
connection: {
database: "my_db",
user: "username",
password: "password",
},
pool: {
min: 2,
max: 10,
},
migrations: {
directory: "./db/migrations",
// tableName: "knex_migrations",
},
},
};
11 changes: 11 additions & 0 deletions models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Knex from "knex";
import { Model } from "objection";
import { Environment } from "types";
import knexConfig from "../knexfile";

const setUpDb = (environment: Environment) => {
const knex = Knex(knexConfig[environment]);
Model.knex(knex);
};

export default setUpDb;
Loading

0 comments on commit c4682ed

Please sign in to comment.