Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sakila SQLite examples #62

Merged
merged 3 commits into from
Sep 17, 2022
Merged

Sakila SQLite examples #62

merged 3 commits into from
Sep 17, 2022

Conversation

billy1624
Copy link
Member

PR Info

For some reason the schema I found at https://github.com/ivanceras/sakila/tree/master/sqlite-sakila-db was a bit off. The customer.active suppose to store 'Y' or 'N', I guess. But in fact the insert statement is putting '1' into the table. So, I decided to change the column type as active SMALLINT DEFAULT 1 NOT NULL.

CREATE TABLE customer (
  customer_id INT NOT NULL,
  store_id INT NOT NULL,
  first_name VARCHAR(45) NOT NULL,
  last_name VARCHAR(45) NOT NULL,
  email VARCHAR(50) DEFAULT NULL,
  address_id INT NOT NULL,
  active CHAR(1) DEFAULT 'Y' NOT NULL,
  create_date TIMESTAMP NOT NULL,
  last_update TIMESTAMP NOT NULL,
  PRIMARY KEY  (customer_id),
  CONSTRAINT fk_customer_store FOREIGN KEY (store_id) REFERENCES store (store_id) ON DELETE NO ACTION ON UPDATE CASCADE,
  CONSTRAINT fk_customer_address FOREIGN KEY (address_id) REFERENCES address (address_id) ON DELETE NO ACTION ON UPDATE CASCADE
)
;

Extracted from https://github.com/ivanceras/sakila/blob/2b3b3a2ae62fc158d0b6e5254d0c1296ccd8d083/sqlite-sakila-db/sqlite-sakila-schema.sql#L186

Insert into customer
 (customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update)
Values
('1','1','MARY','SMITH','MARY.SMITH@sakilacustomer.org','5','1','2006-02-14 22:04:36.000','2006-02-15 04:57:20.000')
;

@billy1624 billy1624 self-assigned this Sep 16, 2022
@@ -14,7 +14,7 @@ categories = ["database"]

[dependencies]
async-std = { version = "1.12.0", features = [ "attributes", "tokio1" ] }
sea-schema = { version = "^0.9.3", default-features = false, features = ["sqlx-sqlite", "sqlx-mysql", "sqlx-postgres", "runtime-async-std-native-tls", "discovery", "writer" ] }
sea-schema = { version = "^0.9.3", git = "https://github.com/SeaQL/sea-schema", default-features = false, features = ["sqlx-sqlite", "sqlx-mysql", "sqlx-postgres", "runtime-async-std-native-tls", "discovery", "writer" ] }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't merge it now. I need to publish SeaSchema 0.9.4 in a bit and bump the version here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SeaSchema 0.9.4 published

@billy1624 billy1624 marked this pull request as ready for review September 16, 2022 14:12
@billy1624
Copy link
Member Author

Good to review and merge

@tyt2y3
Copy link
Member

tyt2y3 commented Sep 17, 2022

Cool let me try it out

@tyt2y3 tyt2y3 merged commit cb005d7 into main Sep 17, 2022
@karatakis karatakis deleted the sqlite-sakila-examples branch September 24, 2022 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Should we have a universal sample schema across different examples?
2 participants