This commit is contained in:
2021-08-17 16:37:14 -05:00
commit bc3f010a5a
8 changed files with 163 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

75
.rustfmt.toml Normal file
View File

@@ -0,0 +1,75 @@
max_width = 70
hard_tabs = false
tab_spaces = 4
newline_style = "Auto"
indent_style = "Block"
use_small_heuristics = "Default"
fn_call_width = 40
attr_fn_like_width = 40
struct_lit_width = 18
struct_variant_width = 35
array_width = 40
chain_width = 40
single_line_if_else_max_width = 50
wrap_comments = true
format_code_in_doc_comments = true
comment_width = 70
normalize_comments = false
normalize_doc_attributes = false
license_template_path = ""
format_strings = true
format_macro_matchers = false
format_macro_bodies = true
empty_item_single_line = true
struct_lit_single_line = true
fn_single_line = false
where_single_line = false
imports_indent = "Block"
imports_layout = "Vertical"
imports_granularity = "Crate"
group_imports = "Preserve"
reorder_imports = true
reorder_modules = true
reorder_impl_items = false
type_punctuation_density = "Wide"
space_before_colon = false
space_after_colon = true
spaces_around_ranges = false
binop_separator = "Back"
remove_nested_parens = true
combine_control_expr = false
overflow_delimited_expr = false
struct_field_align_threshold = 0
enum_discrim_align_threshold = 0
match_arm_blocks = true
match_arm_leading_pipes = "Never"
force_multiline_blocks = true
fn_args_layout = "Vertical"
brace_style = "PreferSameLine"
control_brace_style = "ClosingNextLine"
trailing_semicolon = true
trailing_comma = "Vertical"
match_block_trailing_comma = true
blank_lines_upper_bound = 1
blank_lines_lower_bound = 0
edition = "2018"
version = "One"
inline_attribute_width = 0
merge_derives = false
use_try_shorthand = false
use_field_init_shorthand = false
force_explicit_abi = true
condense_wildcard_suffixes = false
color = "Auto"
required_version = "1.4.37"
unstable_features = false
disable_all_formatting = false
skip_children = false
hide_parse_errors = false
error_on_line_overflow = false
error_on_unformatted = false
report_todo = "Never"
report_fixme = "Never"
ignore = []
emit_mode = "Files"
make_backup = false

8
Cargo.toml Normal file
View File

@@ -0,0 +1,8 @@
[package]
name = "test-sqlx"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

22
Makefile Normal file
View File

@@ -0,0 +1,22 @@
all:
make clean
make build
clean:
rm -rf target
build:
cargo build
test:
cargo test
up:
docker-compose up -d
down:
docker-compose down
run:
cargo run

1
README.md Normal file
View File

@@ -0,0 +1 @@
# sqlx Test

28
db/postgres/init.sql Normal file
View File

@@ -0,0 +1,28 @@
-- a single table is used for all events in the cqrs system
CREATE TABLE events
(
aggregate_type text NOT NULL,
aggregate_id text NOT NULL,
sequence bigint CHECK (sequence >= 0) NOT NULL,
payload jsonb NOT NULL,
metadata jsonb NOT NULL,
timestamp timestamp with time zone DEFAULT (CURRENT_TIMESTAMP),
PRIMARY KEY (aggregate_type, aggregate_id, sequence)
);
CREATE
USER
demo_user
WITH
NOCREATEDB
ENCRYPTED PASSWORD
'demo_pass';
GRANT
ALL PRIVILEGES
ON TABLE
events,
snapshots,
queries
TO
demo_user;

25
docker-compose.yml Normal file
View File

@@ -0,0 +1,25 @@
version: "3.4"
services:
db:
image: postgres
volumes:
- "./db:/docker-entrypoint-initdb.d"
networks:
- default
ports:
- "5433:5432"
environment:
- "POSTGRES_DB=demo"
- "POSTGRES_USER=admin"
- "POSTGRES_PASSWORD=admin_pass"
ui:
image: adminer
restart: always
networks:
- default
ports:
- "8081:8080"
depends_on:
- db

3
src/main.rs Normal file
View File

@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}