-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace elastic with postgresql (#63)
* replace ES with postgresql * update vagrant setup documentation * update Kubernetes setup documentation * fix pr typos
- Loading branch information
1 parent
e6d2d12
commit 592ff98
Showing
71 changed files
with
735 additions
and
857 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const items = require("../db/items.json"); | ||
const { Pool } = require("pg"); | ||
|
||
const pool = new Pool({ | ||
user: process.env.POSTGRES_USER || "kumademo", | ||
host: process.env.POSTGRES_HOST || "localhost", | ||
database: process.env.POSTGRES_DB || "kumademo", | ||
password: process.env.POSTGRES_PASSWORD || "kumademo", | ||
port: process.env.POSTGRES_PORT_NUM || 5432, //POSTGRES_PORT environmental variable is taken on K8S | ||
}); | ||
|
||
pool.on("error", (err, clients) => { | ||
console.error("Unexpected error on idle client", err); | ||
process.exit(-1); | ||
}); | ||
|
||
const search = async (itemName) => { | ||
return await pool.query( | ||
`SELECT data FROM marketItems WHERE name ILIKE '%${itemName}%'` | ||
); | ||
}; | ||
|
||
const importData = () => { | ||
(async () => { | ||
const client = await pool.connect(); | ||
try { | ||
await client.query("BEGIN"); | ||
await client.query("DROP TABLE IF EXISTS marketItems"); | ||
await client.query( | ||
`CREATE TABLE marketItems( | ||
index INTEGER PRIMARY KEY, | ||
name TEXT, | ||
data JSONB | ||
)` | ||
); | ||
items.forEach((item) => { | ||
client.query( | ||
`INSERT INTO marketItems VALUES(${item.index},'${ | ||
item.name | ||
}','${JSON.stringify(item)}')` | ||
); | ||
}); | ||
await client.query("COMMIT"); | ||
} catch (e) { | ||
console.log("Error"); | ||
await client.query("ROLLBACK"); | ||
throw e; | ||
} finally { | ||
console.log("Release"); | ||
client.release(); | ||
} | ||
})().catch((e) => console.error(e.stack)); | ||
}; | ||
|
||
module.exports = Object.assign({ | ||
search, | ||
importData, | ||
}); |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file removed
BIN
-182 Bytes
.../elasticsearch/data/nodes/0/indices/WQK0t2ZtRjGoOXZmy6rN5w/0/_state/retention-leases-1.st
Binary file not shown.
Binary file removed
BIN
-125 Bytes
api/db/elasticsearch/data/nodes/0/indices/WQK0t2ZtRjGoOXZmy6rN5w/0/_state/state-0.st
Binary file not shown.
Binary file removed
BIN
-405 Bytes
api/db/elasticsearch/data/nodes/0/indices/WQK0t2ZtRjGoOXZmy6rN5w/0/index/_0.cfe
Binary file not shown.
Binary file removed
BIN
-75.9 KB
api/db/elasticsearch/data/nodes/0/indices/WQK0t2ZtRjGoOXZmy6rN5w/0/index/_0.cfs
Binary file not shown.
Binary file removed
BIN
-367 Bytes
api/db/elasticsearch/data/nodes/0/indices/WQK0t2ZtRjGoOXZmy6rN5w/0/index/_0.si
Binary file not shown.
Binary file removed
BIN
-364 Bytes
api/db/elasticsearch/data/nodes/0/indices/WQK0t2ZtRjGoOXZmy6rN5w/0/index/segments_4
Binary file not shown.
Empty file removed
0
api/db/elasticsearch/data/nodes/0/indices/WQK0t2ZtRjGoOXZmy6rN5w/0/index/write.lock
Empty file.
Binary file removed
BIN
-55 Bytes
api/db/elasticsearch/data/nodes/0/indices/WQK0t2ZtRjGoOXZmy6rN5w/0/translog/translog-3.tlog
Binary file not shown.
Binary file removed
BIN
-88 Bytes
api/db/elasticsearch/data/nodes/0/indices/WQK0t2ZtRjGoOXZmy6rN5w/0/translog/translog.ckp
Binary file not shown.
Binary file removed
BIN
-621 Bytes
api/db/elasticsearch/data/nodes/0/indices/WQK0t2ZtRjGoOXZmy6rN5w/_state/state-2.st
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# docker build . -t kvn0218/postgres:latest | ||
# docker push kvn0218/postgres:latest | ||
|
||
FROM postgres:alpine | ||
|
||
RUN mkdir -p /tmp/psql_data/ | ||
|
||
RUN echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf | ||
|
||
# Expose the PostgreSQL port | ||
EXPOSE 5432 | ||
|
||
COPY ./database.sql /tmp/psql_data/ | ||
COPY ./init_docker_postgres.sh /docker-entrypoint-initdb.d/ |
Oops, something went wrong.