diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1b50011926a..5677f3d12c92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -260,7 +260,7 @@ jobs: env: BACKEND: ${{ matrix.backend }} run: | - (cd examples/${{ matrix.backend }} && rustup run ${{ matrix.rust }} bash test_all) + (cd examples/${{ matrix.backend }} && rustup run ${{ matrix.rust }} bash test_all) - name: Test migrations-internals shell: bash diff --git a/diesel_cli/Cargo.toml b/diesel_cli/Cargo.toml index a9d2ba62f3f4..05354ffabc87 100644 --- a/diesel_cli/Cargo.toml +++ b/diesel_cli/Cargo.toml @@ -36,7 +36,7 @@ pq-sys = { version = ">=0.4, <0.6.0", optional = true } diffy = "0.3.0" regex = "1.0.6" serde_regex = "1.1" -diesel_table_macro_syntax = {version = "0.1", path = "../diesel_table_macro_syntax"} +diesel_table_macro_syntax = { version = "0.1", path = "../diesel_table_macro_syntax" } syn = { version = "2", features = ["visit"] } tracing = "0.1" tracing-subscriber = { version = "0.3.10", features = ["env-filter"] } diff --git a/diesel_cli/src/cli.rs b/diesel_cli/src/cli.rs index 25bf28de6028..c35fd86568c6 100644 --- a/diesel_cli/src/cli.rs +++ b/diesel_cli/src/cli.rs @@ -148,6 +148,18 @@ pub fn build_cli() -> Command { .num_args(0..=1) .require_equals(true), ) + .arg( + Arg::new("sqlite-integer-primary-key-is-bigint") + .long("sqlite-integer-primary-key-is-bigint") + .requires("SCHEMA_RS") + .action(ArgAction::SetTrue) + .help( + "For SQLite 3.37 and above, detect `INTEGER PRIMARY KEY` columns as `BigInt`, \ + when the table isn't declared with `WITHOUT ROWID`.\n\ + See https://www.sqlite.org/lang_createtable.html#rowid for more information.\n\ + Only used with the `--diff-schema` argument." + ), + ) .arg( Arg::new("table-name") .index(2) @@ -289,6 +301,16 @@ pub fn build_cli() -> Command { .action(clap::ArgAction::Append) .number_of_values(1) .help("A list of derives to implement for every automatically generated SqlType in the schema, separated by commas."), + ) + .arg( + Arg::new("sqlite-integer-primary-key-is-bigint") + .long("sqlite-integer-primary-key-is-bigint") + .action(ArgAction::SetTrue) + .help( + "For SQLite 3.37 and above, detect `INTEGER PRIMARY KEY` columns as `BigInt`, \ + when the table isn't declared with `WITHOUT ROWID`.\n\ + See https://www.sqlite.org/lang_createtable.html#rowid for more information." + ), ); let config_arg = Arg::new("CONFIG_FILE") diff --git a/diesel_cli/src/config.rs b/diesel_cli/src/config.rs index 7a886aef3d4d..889b62317a6d 100644 --- a/diesel_cli/src/config.rs +++ b/diesel_cli/src/config.rs @@ -90,6 +90,8 @@ pub struct PrintSchema { pub generate_missing_sql_type_definitions: Option, #[serde(default)] pub custom_type_derives: Option>, + #[serde(default)] + pub sqlite_integer_primary_key_is_bigint: Option, } impl PrintSchema { diff --git a/diesel_cli/src/infer_schema_internals/inference.rs b/diesel_cli/src/infer_schema_internals/inference.rs index cf7650e0573c..6ef432644acb 100644 --- a/diesel_cli/src/infer_schema_internals/inference.rs +++ b/diesel_cli/src/infer_schema_internals/inference.rs @@ -3,7 +3,7 @@ use diesel::result::Error::NotFound; use super::data_structures::*; use super::table_data::*; -use crate::config::Filtering; +use crate::config::{Filtering, PrintSchema}; use crate::database::InferConnection; use crate::print_schema::{ColumnSorting, DocConfig}; @@ -185,10 +185,14 @@ fn get_column_information( fn determine_column_type( attr: &ColumnInformation, conn: &mut InferConnection, + #[allow(unused_variables)] table: &TableName, + #[allow(unused_variables)] config: &PrintSchema, ) -> Result { match *conn { #[cfg(feature = "sqlite")] - InferConnection::Sqlite(_) => super::sqlite::determine_column_type(attr), + InferConnection::Sqlite(ref mut conn) => { + super::sqlite::determine_column_type(conn, attr, table, config) + } #[cfg(feature = "postgres")] InferConnection::Pg(ref mut conn) => { use crate::infer_schema_internals::information_schema::DefaultSchema; @@ -259,11 +263,10 @@ pub fn load_foreign_key_constraints( pub fn load_table_data( connection: &mut InferConnection, name: TableName, - column_sorting: &ColumnSorting, - with_docs: DocConfig, + config: &PrintSchema, ) -> Result { // No point in loading table comments if they are not going to be displayed - let table_comment = match with_docs { + let table_comment = match config.with_docs { DocConfig::NoDocComments => None, DocConfig::OnlyDatabaseComments | DocConfig::DatabaseCommentsFallbackToAutoGeneratedDocComment => { @@ -275,12 +278,12 @@ pub fn load_table_data( let primary_key = primary_key .iter() .map(|k| rust_name_for_sql_name(k)) - .collect(); + .collect::>(); - let column_data = get_column_information(connection, &name, column_sorting)? + let column_data = get_column_information(connection, &name, &config.column_sorting)? .into_iter() .map(|c| { - let ty = determine_column_type(&c, connection)?; + let ty = determine_column_type(&c, connection, &name, config)?; let ColumnInformation { column_name, diff --git a/diesel_cli/src/infer_schema_internals/sqlite.rs b/diesel_cli/src/infer_schema_internals/sqlite.rs index 272a462c10e2..60263b89cde3 100644 --- a/diesel_cli/src/infer_schema_internals/sqlite.rs +++ b/diesel_cli/src/infer_schema_internals/sqlite.rs @@ -7,6 +7,7 @@ use diesel::*; use super::data_structures::*; use super::table_data::TableName; +use crate::config::PrintSchema; use crate::print_schema::ColumnSorting; table! { @@ -204,6 +205,65 @@ impl QueryableByName for PrimaryKeyInformation { } } +struct WithoutRowIdInformation { + name: String, + without_row_id: bool, +} + +impl QueryableByName for WithoutRowIdInformation { + fn build<'a>(row: &impl NamedRow<'a, Sqlite>) -> deserialize::Result { + Ok(Self { + name: NamedRow::get::(row, "name")?, + without_row_id: NamedRow::get::(row, "wr")?, + }) + } +} + +pub fn column_is_row_id( + conn: &mut SqliteConnection, + table: &TableName, + column_name: &str, + type_name: &str, +) -> Result { + let sqlite_version = get_sqlite_version(conn)?; + if sqlite_version < SqliteVersion::new(3, 37, 0) { + return Err(crate::errors::Error::UnsupportedFeature( + "Parameter `sqlite_integer_primary_key_is_bigint` needs SQLite 3.37 or above".into(), + )); + } + + if type_name != "integer" { + return Ok(false); + } + + let table_xinfo_query = format!("PRAGMA TABLE_XINFO('{}')", &table.sql_name); + let table_xinfo_results = sql_query(table_xinfo_query).load::(conn)?; + + let primary_keys = table_xinfo_results + .iter() + .filter(|pk_info| pk_info.primary_key) + .collect::>(); + + if primary_keys.len() != 1 { + return Ok(false); + } + + if primary_keys[0].name != column_name { + return Ok(false); + } + + let table_list_query = format!("PRAGMA TABLE_LIST('{}')", &table.sql_name); + let table_list_results = sql_query(table_list_query).load::(conn)?; + + let res = table_list_results + .iter() + .find(|wr_info| wr_info.name == table.sql_name) + .map(|wr_info| !wr_info.without_row_id) + .unwrap_or_default(); + + Ok(res) +} + #[derive(Queryable)] struct ForeignKeyListRow { _id: i32, @@ -260,8 +320,13 @@ pub fn get_primary_keys( Ok(collected) } -#[tracing::instrument] -pub fn determine_column_type(attr: &ColumnInformation) -> Result { +#[tracing::instrument(skip(conn))] +pub fn determine_column_type( + conn: &mut SqliteConnection, + attr: &ColumnInformation, + table: &TableName, + config: &PrintSchema, +) -> Result { let mut type_name = attr.type_name.to_lowercase(); if type_name == "generated always" { type_name.clear(); @@ -274,7 +339,17 @@ pub fn determine_column_type(attr: &ColumnInformation) -> Result>(); + + for (table, column_info) in std::iter::zip(&tables, &column_infos) { + let column_type = determine_column_type(&mut conn, column_info, table, &Default::default()); + assert_eq!(column_type.unwrap().sql_name, "Integer"); + } + + let config = PrintSchema { + sqlite_integer_primary_key_is_bigint: Some(true), + ..Default::default() + }; + + let column_types = std::iter::zip(&tables, &column_infos) + .map(|(table, column_info)| { + determine_column_type(&mut conn, column_info, table, &config) + .unwrap() + .sql_name + }) + .collect::>(); + + let expected_column_types = vec![ + "BigInt", "BigInt", "Integer", "Integer", "Integer", "Integer", + ]; + + assert_eq!(column_types, expected_column_types); +} diff --git a/diesel_cli/src/main.rs b/diesel_cli/src/main.rs index 045248292c85..90747dbf2381 100644 --- a/diesel_cli/src/main.rs +++ b/diesel_cli/src/main.rs @@ -286,6 +286,10 @@ fn run_infer_schema(matches: &ArgMatches) -> Result<(), crate::errors::Error> { config.custom_type_derives = Some(derives); } + if matches.get_flag("sqlite-integer-primary-key-is-bigint") { + config.sqlite_integer_primary_key_is_bigint = Some(true); + } + run_print_schema(&mut conn, &config, &mut stdout())?; Ok(()) } diff --git a/diesel_cli/src/migrations/diff_schema.rs b/diesel_cli/src/migrations/diff_schema.rs index 08c05f15d52d..2725c440c35d 100644 --- a/diesel_cli/src/migrations/diff_schema.rs +++ b/diesel_cli/src/migrations/diff_schema.rs @@ -9,13 +9,13 @@ use std::io::Read; use std::path::Path; use syn::visit::Visit; -use crate::config::Config; +use crate::config::{Config, PrintSchema}; use crate::database::InferConnection; use crate::infer_schema_internals::{ filter_table_names, load_table_names, ColumnDefinition, ColumnType, ForeignKeyConstraint, TableData, TableName, }; -use crate::print_schema::DocConfig; +use crate::print_schema::{ColumnSorting, DocConfig}; fn compatible_type_list() -> HashMap<&'static str, Vec<&'static str>> { let mut map = HashMap::new(); @@ -32,7 +32,7 @@ pub fn generate_sql_based_on_diff_schema( matches: &ArgMatches, schema_file_path: &Path, ) -> Result<(String, String), crate::errors::Error> { - let config = config.set_filter(matches)?; + let mut config = config.set_filter(matches)?; let project_root = crate::find_project_root()?; @@ -88,6 +88,21 @@ pub fn generate_sql_based_on_diff_schema( expected_schema_map.insert(t.table_name.to_string(), t); } + config.print_schema.with_docs = DocConfig::NoDocComments; + config.print_schema.column_sorting = ColumnSorting::OrdinalPosition; + + // Parameter `sqlite_integer_primary_key_is_bigint` is only used for a SQLite connection + match conn { + #[cfg(feature = "postgres")] + InferConnection::Pg(_) => config.print_schema.sqlite_integer_primary_key_is_bigint = None, + #[cfg(feature = "sqlite")] + InferConnection::Sqlite(_) => (), + #[cfg(feature = "mysql")] + InferConnection::Mysql(_) => { + config.print_schema.sqlite_integer_primary_key_is_bigint = None; + } + } + let mut schema_diff = Vec::new(); for table in tables_from_database { @@ -95,8 +110,7 @@ pub fn generate_sql_based_on_diff_schema( let columns = crate::infer_schema_internals::load_table_data( &mut conn, table.clone(), - &crate::print_schema::ColumnSorting::OrdinalPosition, - DocConfig::NoDocComments, + &config.print_schema, )?; if let Some(t) = expected_schema_map.remove(&table.sql_name.to_lowercase()) { tracing::info!(table = ?t.sql_name, "Table exists in schema.rs"); @@ -208,19 +222,19 @@ pub fn generate_sql_based_on_diff_schema( #[cfg(feature = "postgres")] InferConnection::Pg(_) => { let mut qb = diesel::pg::PgQueryBuilder::default(); - diff.generate_up_sql(&mut qb)?; + diff.generate_up_sql(&mut qb, &config.print_schema)?; qb.finish() } #[cfg(feature = "sqlite")] InferConnection::Sqlite(_) => { let mut qb = diesel::sqlite::SqliteQueryBuilder::default(); - diff.generate_up_sql(&mut qb)?; + diff.generate_up_sql(&mut qb, &config.print_schema)?; qb.finish() } #[cfg(feature = "mysql")] InferConnection::Mysql(_) => { let mut qb = diesel::mysql::MysqlQueryBuilder::default(); - diff.generate_up_sql(&mut qb)?; + diff.generate_up_sql(&mut qb, &config.print_schema)?; qb.finish() } }; @@ -229,19 +243,19 @@ pub fn generate_sql_based_on_diff_schema( #[cfg(feature = "postgres")] InferConnection::Pg(_) => { let mut qb = diesel::pg::PgQueryBuilder::default(); - diff.generate_down_sql(&mut qb)?; + diff.generate_down_sql(&mut qb, &config.print_schema)?; qb.finish() } #[cfg(feature = "sqlite")] InferConnection::Sqlite(_) => { let mut qb = diesel::sqlite::SqliteQueryBuilder::default(); - diff.generate_down_sql(&mut qb)?; + diff.generate_down_sql(&mut qb, &config.print_schema)?; qb.finish() } #[cfg(feature = "mysql")] InferConnection::Mysql(_) => { let mut qb = diesel::mysql::MysqlQueryBuilder::default(); - diff.generate_down_sql(&mut qb)?; + diff.generate_down_sql(&mut qb, &config.print_schema)?; qb.finish() } }; @@ -311,6 +325,7 @@ impl SchemaDiff { fn generate_up_sql( &self, query_builder: &mut impl QueryBuilder, + config: &PrintSchema, ) -> Result<(), crate::errors::Error> where DB: Backend, @@ -352,12 +367,18 @@ impl SchemaDiff { ) }) .collect::>(); + + let sqlite_integer_primary_key_is_bigint = config + .sqlite_integer_primary_key_is_bigint + .unwrap_or_default(); + generate_create_table( query_builder, table, &column_data, &primary_keys, &foreign_keys, + sqlite_integer_primary_key_is_bigint, )?; } SchemaDiff::ChangeTable { @@ -390,7 +411,11 @@ impl SchemaDiff { Ok(()) } - fn generate_down_sql(&self, query_builder: &mut impl QueryBuilder) -> QueryResult<()> + fn generate_down_sql( + &self, + query_builder: &mut impl QueryBuilder, + config: &PrintSchema, + ) -> QueryResult<()> where DB: Backend, { @@ -411,12 +436,17 @@ impl SchemaDiff { }) .collect::>(); + let sqlite_integer_primary_key_is_bigint = config + .sqlite_integer_primary_key_is_bigint + .unwrap_or_default(); + generate_create_table( query_builder, &table.sql_name.to_lowercase(), &columns.column_data, &columns.primary_key, &fk, + sqlite_integer_primary_key_is_bigint, )?; } SchemaDiff::CreateTable { to_create, .. } => { @@ -428,6 +458,8 @@ impl SchemaDiff { removed_columns, changed_columns, } => { + // We don't need to check the `sqlite_integer_primary_key_is_bigint` parameter here + // since `ÀLTER TABLE` queries cannot modify primary key columns in SQLite. for c in added_columns .iter() .chain(changed_columns.iter().map(|(_, b)| b)) @@ -498,6 +530,7 @@ fn generate_create_table( column_data: &[ColumnDefinition], primary_keys: &[String], foreign_keys: &[(String, String, String)], + sqlite_integer_primary_key_is_bigint: bool, ) -> QueryResult<()> where DB: Backend, @@ -514,11 +547,34 @@ where query_builder.push_sql(",\n"); } query_builder.push_sql("\t"); + + let is_only_primary_key = + primary_keys.contains(&column.rust_name) && primary_keys.len() == 1; + query_builder.push_identifier(&column.sql_name)?; - generate_column_type_name(query_builder, &column.ty); - if primary_keys.contains(&column.rust_name) && primary_keys.len() == 1 { + + // When the `sqlite_integer_primary_key_is_bigint` config parameter is used, + // if a column is the only primary key and its type is `BigInt`, + // we consider it equivalent to the `rowid` column in order to be compatible + // with the `print-schema` command using the same config parameter. + if sqlite_integer_primary_key_is_bigint + && is_only_primary_key + && column.ty.sql_name.eq_ignore_ascii_case("BigInt") + { + let ty = ColumnType { + rust_name: "Integer".into(), + sql_name: "Integer".into(), + ..column.ty.clone() + }; + generate_column_type_name(query_builder, &ty); + } else { + generate_column_type_name(query_builder, &column.ty); + } + + if is_only_primary_key { query_builder.push_sql(" PRIMARY KEY"); } + if let Some((table, _, pk)) = foreign_keys.iter().find(|(_, k, _)| k == &column.rust_name) { foreign_key_list.push((column, table, pk)); } diff --git a/diesel_cli/src/migrations/mod.rs b/diesel_cli/src/migrations/mod.rs index f4785795594b..0d529e354086 100644 --- a/diesel_cli/src/migrations/mod.rs +++ b/diesel_cli/src/migrations/mod.rs @@ -91,12 +91,15 @@ pub(super) fn run_migration_command(matches: &ArgMatches) -> Result<(), crate::e let (up_sql, down_sql) = if let Some(diff_schema) = args.get_one::("SCHEMA_RS") { - let config = Config::read(matches)?; + let mut config = Config::read(matches)?; let diff_schema = if diff_schema == "NOT_SET" { config.print_schema.file.clone() } else { Some(PathBuf::from(diff_schema)) }; + if args.get_flag("sqlite-integer-primary-key-is-bigint") { + config.print_schema.sqlite_integer_primary_key_is_bigint = Some(true); + } if let Some(diff_schema) = diff_schema { self::diff_schema::generate_sql_based_on_diff_schema( config, diff --git a/diesel_cli/src/print_schema.rs b/diesel_cli/src/print_schema.rs index 5217192dd345..76e6573e5187 100644 --- a/diesel_cli/src/print_schema.rs +++ b/diesel_cli/src/print_schema.rs @@ -157,7 +157,7 @@ pub fn output_schema( remove_unsafe_foreign_keys_for_codegen(connection, &foreign_keys, &table_names); let table_data = table_names .into_iter() - .map(|t| load_table_data(connection, t, &config.column_sorting, config.with_docs)) + .map(|t| load_table_data(connection, t, config)) .collect::, crate::errors::Error>>()?; let mut out = String::new(); diff --git a/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/schema.rs b/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/schema.rs new file mode 100644 index 000000000000..bcb1d8b16565 --- /dev/null +++ b/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/schema.rs @@ -0,0 +1,6 @@ +table! { + users { + id -> BigInt, + name -> Text, + } +} diff --git a/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/down.sql/expected.snap b/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/down.sql/expected.snap new file mode 100644 index 000000000000..6bf6dc40cefc --- /dev/null +++ b/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/down.sql/expected.snap @@ -0,0 +1,7 @@ +--- +source: diesel_cli/tests/migration_generate.rs +description: "Test: diff_add_table" +--- +-- This file should undo anything in `up.sql` +DROP TABLE IF EXISTS `users`; + diff --git a/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/initial_schema.sql b/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/initial_schema.sql new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/initial_schema.sql @@ -0,0 +1 @@ + diff --git a/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/schema_out.rs/expected.snap b/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/schema_out.rs/expected.snap new file mode 100644 index 000000000000..0f8d10baa63e --- /dev/null +++ b/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/schema_out.rs/expected.snap @@ -0,0 +1,12 @@ +--- +source: diesel_cli/tests/migration_generate.rs +description: "Test: diff_add_table" +--- +// @generated automatically by Diesel CLI. + +diesel::table! { + users (id) { + id -> BigInt, + name -> Text, + } +} diff --git a/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/up.sql/expected.snap b/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/up.sql/expected.snap new file mode 100644 index 000000000000..a53abfe52623 --- /dev/null +++ b/diesel_cli/tests/generate_migrations/diff_add_table_sqlite_rowid_column/sqlite/up.sql/expected.snap @@ -0,0 +1,10 @@ +--- +source: diesel_cli/tests/migration_generate.rs +description: "Test: diff_add_table" +--- +-- Your SQL goes here +CREATE TABLE `users`( + `id` INTEGER NOT NULL PRIMARY KEY, + `name` TEXT NOT NULL +); + diff --git a/diesel_cli/tests/migration_generate.rs b/diesel_cli/tests/migration_generate.rs index 1c6deafa663b..fd2169b24615 100644 --- a/diesel_cli/tests/migration_generate.rs +++ b/diesel_cli/tests/migration_generate.rs @@ -220,6 +220,14 @@ fn migration_generate_from_diff_add_table() { test_generate_migration("diff_add_table", Vec::new()); } +#[test] +fn migration_generate_from_diff_add_table_sqlite_rowid_column() { + test_generate_migration( + "diff_add_table_sqlite_rowid_column", + vec!["--sqlite-integer-primary-key-is-bigint"], + ); +} + #[test] fn migration_generate_from_diff_drop_alter_table_add_column() { test_generate_migration("diff_alter_table_add_column", Vec::new()); diff --git a/diesel_cli/tests/print_schema.rs b/diesel_cli/tests/print_schema.rs index dd298713b81a..e867a2e09edf 100644 --- a/diesel_cli/tests/print_schema.rs +++ b/diesel_cli/tests/print_schema.rs @@ -250,6 +250,15 @@ fn print_schema_generated_columns_with_generated_always() { test_print_schema("print_schema_generated_columns_generated_always", vec![]) } +#[test] +#[cfg(feature = "sqlite")] +fn print_schema_sqlite_rowid_column() { + test_print_schema( + "print_schema_sqlite_rowid_column", + vec!["--sqlite-integer-primary-key-is-bigint"], + ) +} + #[test] #[cfg(feature = "postgres")] fn print_schema_multiple_annotations() { diff --git a/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/diesel.toml b/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/diesel.toml new file mode 100644 index 000000000000..e914c1be0c32 --- /dev/null +++ b/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/diesel.toml @@ -0,0 +1,4 @@ +[print_schema] +file = "src/schema.rs" +with_docs = false +sqlite_integer_primary_key_is_bigint = true diff --git a/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/sqlite/expected.snap b/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/sqlite/expected.snap new file mode 100644 index 000000000000..35a5caa9dfa8 --- /dev/null +++ b/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/sqlite/expected.snap @@ -0,0 +1,11 @@ +--- +source: diesel_cli/tests/print_schema.rs +description: "Test: print_schema_sqlite_rowid_column" +--- +// @generated automatically by Diesel CLI. + +diesel::table! { + users (id) { + id -> BigInt, + } +} diff --git a/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/sqlite/schema.sql b/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/sqlite/schema.sql new file mode 100644 index 000000000000..78caa07cad3f --- /dev/null +++ b/diesel_cli/tests/print_schema/print_schema_sqlite_rowid_column/sqlite/schema.sql @@ -0,0 +1 @@ +CREATE TABLE users (id INTEGER NOT NULL PRIMARY KEY);